|
5 | 5 | from roundup.date import Date, Interval |
6 | 6 | from roundup.cgi.actions import * |
7 | 7 | from roundup.cgi.client import add_message |
8 | | -from roundup.cgi.exceptions import Redirect, Unauthorised, SeriousError |
| 8 | +from roundup.cgi.exceptions import Redirect, Unauthorised, SeriousError, FormError |
9 | 9 |
|
10 | 10 | from mocknull import MockNull |
11 | 11 |
|
@@ -135,6 +135,34 @@ def testStringKey(self): |
135 | 135 | self.form.value.append(MiniFieldStorage('foo', 'hello')) |
136 | 136 | self.assertFilterEquals('foo') |
137 | 137 |
|
| 138 | + def testNumKey(self): # testing patch: http://hg.python.org/tracker/roundup/rev/98508a47c126 |
| 139 | + for val in [ "-1000a", "test", "o0.9999", "o0", "1.00/10" ]: |
| 140 | + print "testing ", val |
| 141 | + self.client.db.classes.get_transitive_prop = lambda x: hyperdb.Number() |
| 142 | + self.form.value.append(MiniFieldStorage('foo', val)) # invalid numbers |
| 143 | + self.assertRaises(FormError, self.action.fakeFilterVars) |
| 144 | + del self.form.value[:] |
| 145 | + |
| 146 | + for val in [ "-1000.7738", "-556", "-0.9999", "-.456", "-5E-5", "0.00", "0", |
| 147 | + "1.00", "0556", "7.56E2", "1000.7738"]: |
| 148 | + self.form.value.append(MiniFieldStorage('foo', val)) |
| 149 | + self.action.fakeFilterVars() # this should run and return. No errors, nothing to check. |
| 150 | + del self.form.value[:] |
| 151 | + |
| 152 | + def testIntKey(self): # testing patch: http://hg.python.org/tracker/roundup/rev/98508a47c126 |
| 153 | + for val in [ "-1000a", "test", "-5E-5", "0.9999", "0.0", "1.000", "0456", "1E4" ]: |
| 154 | + print "testing ", val |
| 155 | + self.client.db.classes.get_transitive_prop = lambda x: hyperdb.Integer() |
| 156 | + self.form.value.append(MiniFieldStorage('foo', val)) |
| 157 | + self.assertRaises(FormError, self.action.fakeFilterVars) |
| 158 | + del self.form.value[:] |
| 159 | + |
| 160 | + for val in [ "-1000", "-512", "0", "1", "100", "248" ]: # no scientific notation apparently |
| 161 | + self.client.db.classes.get_transitive_prop = lambda x: hyperdb.Integer() |
| 162 | + self.form.value.append(MiniFieldStorage('foo', val)) |
| 163 | + self.action.fakeFilterVars() # this should run and return. No errors, nothing to check. |
| 164 | + del self.form.value[:] |
| 165 | + |
138 | 166 | def testTokenizedStringKey(self): |
139 | 167 | self.client.db.classes.get_transitive_prop = lambda x: hyperdb.String() |
140 | 168 | self.form.value.append(MiniFieldStorage('foo', 'hello world')) |
|
0 commit comments