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