Mercurial > p > roundup > code
annotate test/test_cgi.py @ 1371:56c5b4509378 maint-0.5
revert StringHTMLProperty to not hyperlink text by default (added doc too)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 13 Jan 2003 04:24:54 +0000 |
| parents | |
| children | a87f59436895 |
| rev | line source |
|---|---|
|
1371
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 # Copyright (c) 2003 Richard Jones, rjones@ekit-inc.com |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 # This module is free software, and you may redistribute it and/or modify |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 # under the same terms as Python, so long as this copyright message and |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 # disclaimer are retained in their original form. |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 # This module is distributed in the hope that it will be useful, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 # $Id: test_cgi.py,v 1.4 2003-01-15 11:14:01 richard Exp $ |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 import unittest, os, shutil, errno, sys, difflib, cgi |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 from roundup.cgi import client |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 from roundup import init, instance, password |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 def makeForm(args): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 form = cgi.FieldStorage() |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 for k,v in args.items(): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 if type(v) is type([]): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 [form.list.append(cgi.MiniFieldStorage(k, x)) for x in v] |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 else: |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 form.list.append(cgi.MiniFieldStorage(k, v)) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 return form |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 class FormTestCase(unittest.TestCase): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 def setUp(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 self.dirname = '_test_cgi_form' |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 try: |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 shutil.rmtree(self.dirname) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 except OSError, error: |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 # create the instance |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 init.install(self.dirname, 'classic', 'anydbm') |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 init.initialise(self.dirname, 'sekrit') |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 # check we can load the package |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 self.instance = instance.open(self.dirname) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 # and open the database |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 self.db = self.instance.open('admin') |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 self.db.user.create(username='Chef', address='chef@bork.bork.bork', |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 realname='Bork, Chef', roles='User') |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 self.db.user.create(username='mary', address='mary@test', |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 roles='User', realname='Contrary, Mary') |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 def tearDown(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 self.db.close() |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 try: |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 shutil.rmtree(self.dirname) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 except OSError, error: |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 # Empty form |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 def testNothing(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 makeForm({})), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
59 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 def testNothingWithRequired(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 form = makeForm({':required': 'title'}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 self.db.issue, form) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 # String |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
68 def testEmptyString(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
69 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 makeForm({'title': ''})), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 makeForm({'title': ' '})), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 self.db.issue, makeForm({'title': ['', '']})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
76 def testSetString(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
77 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 makeForm({'title': 'foo'})), {'title': 'foo'}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 makeForm({'title': 'a\r\nb\r\n'})), {'title': 'a\nb'}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 def testEmptyStringSet(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 nodeid = self.db.issue.create(title='foo') |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
85 makeForm({'title': ''}), nodeid), {'title': ''}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
86 nodeid = self.db.issue.create(title='foo') |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
87 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
88 makeForm({'title': ' '}), nodeid), {'title': ''}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
89 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
91 # Multilink |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
92 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
93 def testEmptyMultilink(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
94 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
95 makeForm({'nosy': ''})), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
96 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
97 makeForm({'nosy': ' '})), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
98 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
99 def testSetMultilink(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
100 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
101 makeForm({'nosy': '1'})), {'nosy': ['1']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
102 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
103 makeForm({'nosy': 'admin'})), {'nosy': ['1']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
104 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
105 makeForm({'nosy': ['1','2']})), {'nosy': ['1','2']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
106 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
107 makeForm({'nosy': '1,2'})), {'nosy': ['1','2']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
108 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
109 makeForm({'nosy': 'admin,2'})), {'nosy': ['1','2']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
110 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
111 def testEmptyMultilinkSet(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
112 nodeid = self.db.issue.create(nosy=['1','2']) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
113 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
114 makeForm({'nosy': ''}), nodeid), {'nosy': []}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
115 nodeid = self.db.issue.create(nosy=['1','2']) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
116 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
117 makeForm({'nosy': ' '}), nodeid), {'nosy': []}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
118 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
119 def testInvalidMultilinkValue(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
120 # XXX This is not the current behaviour - should we enforce this? |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
121 # self.assertRaises(IndexError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
122 # self.db.issue, makeForm({'nosy': '4'})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
123 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
124 self.db.issue, makeForm({'nosy': 'frozzle'})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
125 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
126 self.db.issue, makeForm({'nosy': '1,frozzle'})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
127 # XXX need a test for the TypeError (where the ML class doesn't define a key |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
128 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
129 def testMultilinkAdd(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
130 nodeid = self.db.issue.create(nosy=['1']) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
131 # do nothing |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
132 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
133 makeForm({':add:nosy': ''}), nodeid), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
134 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
135 # do something ;) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
136 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
137 makeForm({':add:nosy': '2'}), nodeid), {'nosy': ['1','2']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
138 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
139 makeForm({':add:nosy': '2,mary'}), nodeid), {'nosy': ['1','2','4']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
140 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
141 makeForm({':add:nosy': ['2','3']}), nodeid), {'nosy': ['1','2','3']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
142 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
143 def testMultilinkAddNew(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 makeForm({':add:nosy': ['2','3']})), {'nosy': ['2','3']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
147 def testMultilinkRemove(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
148 nodeid = self.db.issue.create(nosy=['1','2']) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
149 # do nothing |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
150 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
151 makeForm({':remove:nosy': ''}), nodeid), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
152 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
153 # do something ;) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
154 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
155 makeForm({':remove:nosy': '1'}), nodeid), {'nosy': ['2']}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
156 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
157 makeForm({':remove:nosy': 'admin,2'}), nodeid), {'nosy': []}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
158 self.assertEqual(client.parsePropsFromForm(self.db, self.db.issue, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
159 makeForm({':remove:nosy': ['1','2']}), nodeid), {'nosy': []}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
160 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
161 # remove one that doesn't exist? |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
162 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
163 self.db.issue, makeForm({':remove:nosy': '4'}), nodeid) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
164 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
165 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
166 # Password |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
167 # |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
168 def testEmptyPassword(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
169 self.assertEqual(client.parsePropsFromForm(self.db, self.db.user, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
170 makeForm({'password': ''})), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
171 self.assertEqual(client.parsePropsFromForm(self.db, self.db.user, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
172 makeForm({'password': ''})), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
173 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
174 self.db.user, makeForm({'password': ['', '']})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
175 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
176 self.db.user, makeForm({'password': 'foo', |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
177 'password:confirm': ['', '']})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
178 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
179 def testSetPassword(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
180 self.assertEqual(client.parsePropsFromForm(self.db, self.db.user, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
181 makeForm({'password': 'foo', 'password:confirm': 'foo'})), |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
182 {'password': 'foo'}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
183 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
184 def testSetPasswordConfirmBad(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
185 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
186 self.db.user, makeForm({'password': 'foo'})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
187 self.assertRaises(ValueError, client.parsePropsFromForm, self.db, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
188 self.db.user, makeForm({'password': 'foo', |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
189 'password:confirm': 'bar'})) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
190 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
191 def testEmptyPasswordNOTSet(self): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
192 nodeid = self.db.user.create(username='1', password=password.Password('foo')) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
193 self.assertEqual(client.parsePropsFromForm(self.db, self.db.user, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
194 makeForm({'password': ''}), nodeid), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
195 nodeid = self.db.user.create(username='2', password=password.Password('foo')) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
196 self.assertEqual(client.parsePropsFromForm(self.db, self.db.user, |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
197 makeForm({'password': '', 'password:confirm': ''}), nodeid), {}) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
198 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
199 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
200 def suite(): |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
201 l = [unittest.makeSuite(FormTestCase), |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
202 ] |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
203 return unittest.TestSuite(l) |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
204 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
205 |
|
56c5b4509378
revert StringHTMLProperty to not hyperlink text by default (added doc too)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
206 # vim: set filetype=python ts=4 sw=4 et si |
