Code

Updated to version 1.4 (python 2.2) version of pygettext
[roundup.git] / test / test_schema.py
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.6 2001-12-03 21:33:39 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 SchemaTestCase(unittest.TestCase):
27     def setUp(self):
28         class Database(anydbm.Database):
29             pass
30         # remove previous test, ignore errors
31         if os.path.exists('_test_dir'):
32             shutil.rmtree('_test_dir')
33         os.mkdir('_test_dir')
34         self.db = Database('_test_dir', 'test')
35         self.db.clear()
37     def tearDown(self):
38         shutil.rmtree('_test_dir')
40     def testA_Status(self):
41         status = Class(self.db, "status", name=String())
42         self.assert_(status, 'no class object generated')
43         status.setkey("name")
44         val = status.create(name="unread")
45         self.assertEqual(val, '1', 'expecting "1"')
46         val = status.create(name="in-progress")
47         self.assertEqual(val, '2', 'expecting "2"')
48         val = status.create(name="testing")
49         self.assertEqual(val, '3', 'expecting "3"')
50         val = status.create(name="resolved")
51         self.assertEqual(val, '4', 'expecting "4"')
52         val = status.count()
53         self.assertEqual(val, 4, 'expecting 4')
54         val = status.list()
55         self.assertEqual(val, ['1', '2', '3', '4'], 'blah')
56         val = status.lookup("in-progress")
57         self.assertEqual(val, '2', 'expecting "2"')
58         status.retire('3')
59         val = status.list()
60         self.assertEqual(val, ['1', '2', '4'], 'blah')
62     def testB_Issue(self):
63         issue = Class(self.db, "issue", title=String(), status=Link("status"))
64         self.assert_(issue, 'no class object returned')
66     def testC_User(self):
67         user = Class(self.db, "user", username=String(), password=Password())
68         self.assert_(user, 'no class object returned')
69         user.setkey("username")
72 def suite():
73    return unittest.makeSuite(SchemaTestCase, 'test')
76 #
77 # $Log: not supported by cvs2svn $
78 # Revision 1.5  2001/10/09 07:25:59  richard
79 # Added the Password property type. See "pydoc roundup.password" for
80 # implementation details. Have updated some of the documentation too.
81 #
82 # Revision 1.4  2001/08/07 00:24:43  richard
83 # stupid typo
84 #
85 # Revision 1.3  2001/08/07 00:15:51  richard
86 # Added the copyright/license notice to (nearly) all files at request of
87 # Bizar Software.
88 #
89 # Revision 1.2  2001/07/29 07:01:39  richard
90 # Added vim command to all source so that we don't get no steenkin' tabs :)
91 #
92 # Revision 1.1  2001/07/27 06:55:07  richard
93 # moving tests -> test
94 #
95 # Revision 1.3  2001/07/25 04:34:31  richard
96 # Added id and log to tests files...
97 #
98 #
99 # vim: set filetype=python ts=4 sw=4 et si