comparison test/test_templating.py @ 8305:a81a3cd067fa

Generate savepoint only if necessary Now some methods got an additional 'allow_abort' parameter. By default this is True. When False the postgres backend generates a savepoint. The methods are called with allow_abort=False from some of the cgi methods which can produce a traceback when called with data from the web-interface.
author Ralf Schlatterbeck <rsc@runtux.com>
date Sat, 01 Mar 2025 18:55:54 +0100
parents b99e76e76496
children 4455cd036c25
comparison
equal deleted inserted replaced
8304:24549122f9b1 8305:a81a3cd067fa
141 141
142 # This keeps db.issue static, otherwise it changes for each call 142 # This keeps db.issue static, otherwise it changes for each call
143 db = MockNull(issue = HTMLDatabase(self.client).issue) 143 db = MockNull(issue = HTMLDatabase(self.client).issue)
144 db.issue._klass.list = lambda : ['23', 'a', 'b'] 144 db.issue._klass.list = lambda : ['23', 'a', 'b']
145 # Make db.getclass return something that has a sensible 'get' method 145 # Make db.getclass return something that has a sensible 'get' method
146 mock = MockNull(get = lambda x, y : None) 146 def get(x, y, allow_abort=True):
147 return None
148 mock = MockNull(get = get)
147 db.issue._db.getclass = lambda x : mock 149 db.issue._db.getclass = lambda x : mock
148 l = db.issue.list() 150 l = db.issue.list()
149 151
150 class FunctionsTestCase(TemplatingTestCase): 152 class FunctionsTestCase(TemplatingTestCase):
151 def test_lookupIds(self): 153 def test_lookupIds(self):
168 self.assertEqual(lookupIds(db._db, prop, ['ok', '@current_user']), 170 self.assertEqual(lookupIds(db._db, prop, ['ok', '@current_user']),
169 ['1']) 171 ['1'])
170 172
171 def test_lookupKeys(self): 173 def test_lookupKeys(self):
172 db = HTMLDatabase(self.client) 174 db = HTMLDatabase(self.client)
173 def get(entry, key): 175 def get(entry, key, allow_abort=True):
174 return {'1': 'green', '2': 'eggs'}.get(entry, entry) 176 return {'1': 'green', '2': 'eggs'}.get(entry, entry)
175 shrubbery = MockNull(get=get) 177 shrubbery = MockNull(get=get)
176 db._db.classes = {'shrubbery': shrubbery} 178 db._db.classes = {'shrubbery': shrubbery}
177 self.assertEqual(lookupKeys(shrubbery, 'spam', ['1','2']), 179 self.assertEqual(lookupKeys(shrubbery, 'spam', ['1','2']),
178 ['green', 'eggs']) 180 ['green', 'eggs'])

Roundup Issue Tracker: http://roundup-tracker.org/