Code

Removed the unnecessary volatiledb and the related complications. Security
[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.8 2002-07-14 02:05:54 richard Exp $ 
20 import unittest, os, shutil
22 from roundup.backends import back_anydbm
23 from roundup.hyperdb import String, Password, Link, Multilink, Date, \
24     Interval
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         # remove previous test, ignore errors
43         if os.path.exists(config.DATABASE):
44             shutil.rmtree(config.DATABASE)
45         os.makedirs(config.DATABASE + '/files')
46         self.db = back_anydbm.Database(config, 'test')
47         self.db.clear()
49     def tearDown(self):
50         shutil.rmtree('_test_dir')
52     def testA_Status(self):
53         status = back_anydbm.Class(self.db, "status", name=String())
54         self.assert_(status, 'no class object generated')
55         status.setkey("name")
56         val = status.create(name="unread")
57         self.assertEqual(val, '1', 'expecting "1"')
58         val = status.create(name="in-progress")
59         self.assertEqual(val, '2', 'expecting "2"')
60         val = status.create(name="testing")
61         self.assertEqual(val, '3', 'expecting "3"')
62         val = status.create(name="resolved")
63         self.assertEqual(val, '4', 'expecting "4"')
64         val = status.count()
65         self.assertEqual(val, 4, 'expecting 4')
66         val = status.list()
67         self.assertEqual(val, ['1', '2', '3', '4'], 'blah')
68         val = status.lookup("in-progress")
69         self.assertEqual(val, '2', 'expecting "2"')
70         status.retire('3')
71         val = status.list()
72         self.assertEqual(val, ['1', '2', '4'], 'blah')
74     def testB_Issue(self):
75         issue = back_anydbm.Class(self.db, "issue", title=String(),
76             status=Link("status"))
77         self.assert_(issue, 'no class object returned')
79     def testC_User(self):
80         user = back_anydbm.Class(self.db, "user", username=String(),
81             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.7  2002/01/14 02:20:15  richard
93 #  . changed all config accesses so they access either the instance or the
94 #    config attriubute on the db. This means that all config is obtained from
95 #    instance_config instead of the mish-mash of classes. This will make
96 #    switching to a ConfigParser setup easier too, I hope.
97 #
98 # At a minimum, this makes migration a _little_ easier (a lot easier in the
99 # 0.5.0 switch, I hope!)
101 # Revision 1.6  2001/12/03 21:33:39  richard
102 # Fixes so the tests use commit and not close
104 # Revision 1.5  2001/10/09 07:25:59  richard
105 # Added the Password property type. See "pydoc roundup.password" for
106 # implementation details. Have updated some of the documentation too.
108 # Revision 1.4  2001/08/07 00:24:43  richard
109 # stupid typo
111 # Revision 1.3  2001/08/07 00:15:51  richard
112 # Added the copyright/license notice to (nearly) all files at request of
113 # Bizar Software.
115 # Revision 1.2  2001/07/29 07:01:39  richard
116 # Added vim command to all source so that we don't get no steenkin' tabs :)
118 # Revision 1.1  2001/07/27 06:55:07  richard
119 # moving tests -> test
121 # Revision 1.3  2001/07/25 04:34:31  richard
122 # Added id and log to tests files...
125 # vim: set filetype=python ts=4 sw=4 et si