Mercurial > p > roundup > code
annotate test/test_misc.py @ 5548:fea11d05110e
Avoid errors from selecting "no selection" on multilink (issue2550722).
As discussed in issue 2550722 there are various cases where selecting
"no selection" on a multilink can result in inappropriate errors from
Roundup:
* If selecting "no selection" produces a null edit (a value was set in
the multilink in an edit with an error, then removed again, along
with all other changes, in the next form submission), so the page is
rendered from the form contents including the "-<id>" value for "no
selection" for the multilink.
* If creating an item with a nonempty value for a multilink has an
error, and the resubmission changes that multilink to "no selection"
(and this in turn has subcases, according to whether the creation
then succeeds or fails on the resubmission, which need fixes in
different places in the Roundup code).
All of these cases have in common that it is expected and OK to have a
"-<id>" value for a submission for a multilink when <id> is not set in
that multilink in the database (because the original attempt to set
<id> in that multilink had an error), so the hyperdb.py logic to give
an error in that case is thus removed. In the subcase of the second
case where the resubmission with "no selection" has an error, the
templating code tries to produce a menu entry for the "-<id>"
multilink value, which also results in an error, hence the
templating.py change to ignore such values in the list for a
multilink.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Thu, 27 Sep 2018 11:33:01 +0000 |
| parents | 9a09719b0d8e |
| children | 3b945aee0919 |
| rev | line source |
|---|---|
|
5155
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1 # misc tests |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2 |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
3 import unittest |
|
5481
9a09719b0d8e
helper to allow comparing dicts and None values in Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5155
diff
changeset
|
4 import roundup.anypy.cmp_ |
|
5155
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
5 from roundup.cgi.accept_language import parse |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
6 |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
7 class AcceptLanguageTest(unittest.TestCase): |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
8 def testParse(self): |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
9 self.assertEqual(parse("da, en-gb;q=0.8, en;q=0.7"), |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
10 ['da', 'en_gb', 'en']) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
11 self.assertEqual(parse("en;q=0.2, fr;q=1"), ['fr', 'en']) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
12 self.assertEqual(parse("zn; q = 0.2 ,pt-br;q =1"), ['pt_br', 'zn']) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
13 self.assertEqual(parse("es-AR"), ['es_AR']) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
14 self.assertEqual(parse("es-es-cat"), ['es_es_cat']) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
15 self.assertEqual(parse(""), []) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
16 self.assertEqual(parse(None),[]) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
17 self.assertEqual(parse(" "), []) |
|
e1e3531b4d9b
add tests for roundup/cgi/accept_language.py copied from embedded doctests already in file.
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
18 self.assertEqual(parse("en,"), ['en']) |
|
5481
9a09719b0d8e
helper to allow comparing dicts and None values in Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5155
diff
changeset
|
19 |
|
9a09719b0d8e
helper to allow comparing dicts and None values in Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5155
diff
changeset
|
20 class CmpTest(unittest.TestCase): |
|
9a09719b0d8e
helper to allow comparing dicts and None values in Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5155
diff
changeset
|
21 def testCmp(self): |
|
9a09719b0d8e
helper to allow comparing dicts and None values in Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5155
diff
changeset
|
22 roundup.anypy.cmp_._test() |
