Mercurial > p > roundup > code
comparison test/test_templating.py @ 6689:994893cf3e1a
Fix traceback if an order attribute is None
Fixes issue2551207.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Mon, 30 May 2022 18:03:39 +0200 |
| parents | b598b46eb427 |
| children | 38b73f7495f8 |
comparison
equal
deleted
inserted
replaced
| 6688:f1f2d59dab8b | 6689:994893cf3e1a |
|---|---|
| 105 | 105 |
| 106 def test_HTMLDatabase_classes(self): | 106 def test_HTMLDatabase_classes(self): |
| 107 db = HTMLDatabase(self.client) | 107 db = HTMLDatabase(self.client) |
| 108 db._db.classes = {'issue':MockNull(), 'user': MockNull()} | 108 db._db.classes = {'issue':MockNull(), 'user': MockNull()} |
| 109 db.classes() | 109 db.classes() |
| 110 | |
| 111 def test_HTMLDatabase_list(self): | |
| 112 # The list method used to produce a traceback when a None value | |
| 113 # for an order attribute of a class was encountered. This | |
| 114 # happens when the 'get' of the order attribute for a numeric | |
| 115 # id produced a None value. So we put '23' as a key into the | |
| 116 # list and set things up that a None value is returned on 'get'. | |
| 117 | |
| 118 # This keeps db.issue static, otherwise it changes for each call | |
| 119 db = MockNull(issue = HTMLDatabase(self.client).issue) | |
| 120 db.issue._klass.list = lambda : ['23', 'a', 'b'] | |
| 121 # Make db.getclass return something that has a sensible 'get' method | |
| 122 mock = MockNull(get = lambda x, y : None) | |
| 123 db.issue._db.getclass = lambda x : mock | |
| 124 l = db.issue.list() | |
| 110 | 125 |
| 111 class FunctionsTestCase(TemplatingTestCase): | 126 class FunctionsTestCase(TemplatingTestCase): |
| 112 def test_lookupIds(self): | 127 def test_lookupIds(self): |
| 113 db = HTMLDatabase(self.client) | 128 db = HTMLDatabase(self.client) |
| 114 def lookup(key): | 129 def lookup(key): |
