88ac024344a63b0172f7c39b9c67d1c14dd69064
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 #
18 # $Id: test_schema.py,v 1.7 2002-01-14 02:20:15 richard Exp $
20 import unittest, os, shutil
22 from roundup.backends import anydbm
23 from roundup.hyperdb import String, Password, Link, Multilink, Date, \
24 Interval, Class
26 class config:
27 DATABASE='_test_dir'
28 MAILHOST = 'localhost'
29 MAIL_DOMAIN = 'fill.me.in.'
30 INSTANCE_NAME = 'Roundup issue tracker'
31 ISSUE_TRACKER_EMAIL = 'issue_tracker@%s'%MAIL_DOMAIN
32 ISSUE_TRACKER_WEB = 'http://some.useful.url/'
33 ADMIN_EMAIL = 'roundup-admin@%s'%MAIL_DOMAIN
34 FILTER_POSITION = 'bottom' # one of 'top', 'bottom', 'top and bottom'
35 ANONYMOUS_ACCESS = 'deny' # either 'deny' or 'allow'
36 ANONYMOUS_REGISTER = 'deny' # either 'deny' or 'allow'
37 MESSAGES_TO_AUTHOR = 'no' # either 'yes' or 'no'
38 EMAIL_SIGNATURE_POSITION = 'bottom'
40 class SchemaTestCase(unittest.TestCase):
41 def setUp(self):
42 class Database(anydbm.Database):
43 pass
44 # remove previous test, ignore errors
45 if os.path.exists(config.DATABASE):
46 shutil.rmtree(config.DATABASE)
47 os.makedirs(config.DATABASE + '/files')
48 self.db = Database(config, 'test')
49 self.db.clear()
51 def tearDown(self):
52 shutil.rmtree('_test_dir')
54 def testA_Status(self):
55 status = Class(self.db, "status", name=String())
56 self.assert_(status, 'no class object generated')
57 status.setkey("name")
58 val = status.create(name="unread")
59 self.assertEqual(val, '1', 'expecting "1"')
60 val = status.create(name="in-progress")
61 self.assertEqual(val, '2', 'expecting "2"')
62 val = status.create(name="testing")
63 self.assertEqual(val, '3', 'expecting "3"')
64 val = status.create(name="resolved")
65 self.assertEqual(val, '4', 'expecting "4"')
66 val = status.count()
67 self.assertEqual(val, 4, 'expecting 4')
68 val = status.list()
69 self.assertEqual(val, ['1', '2', '3', '4'], 'blah')
70 val = status.lookup("in-progress")
71 self.assertEqual(val, '2', 'expecting "2"')
72 status.retire('3')
73 val = status.list()
74 self.assertEqual(val, ['1', '2', '4'], 'blah')
76 def testB_Issue(self):
77 issue = Class(self.db, "issue", title=String(), status=Link("status"))
78 self.assert_(issue, 'no class object returned')
80 def testC_User(self):
81 user = Class(self.db, "user", username=String(), password=Password())
82 self.assert_(user, 'no class object returned')
83 user.setkey("username")
86 def suite():
87 return unittest.makeSuite(SchemaTestCase, 'test')
90 #
91 # $Log: not supported by cvs2svn $
92 # Revision 1.6 2001/12/03 21:33:39 richard
93 # Fixes so the tests use commit and not close
94 #
95 # Revision 1.5 2001/10/09 07:25:59 richard
96 # Added the Password property type. See "pydoc roundup.password" for
97 # implementation details. Have updated some of the documentation too.
98 #
99 # Revision 1.4 2001/08/07 00:24:43 richard
100 # stupid typo
101 #
102 # Revision 1.3 2001/08/07 00:15:51 richard
103 # Added the copyright/license notice to (nearly) all files at request of
104 # Bizar Software.
105 #
106 # Revision 1.2 2001/07/29 07:01:39 richard
107 # Added vim command to all source so that we don't get no steenkin' tabs :)
108 #
109 # Revision 1.1 2001/07/27 06:55:07 richard
110 # moving tests -> test
111 #
112 # Revision 1.3 2001/07/25 04:34:31 richard
113 # Added id and log to tests files...
114 #
115 #
116 # vim: set filetype=python ts=4 sw=4 et si