comparison test/db_test_base.py @ 5468:0cde8a595893

fix tests for Python 3 don't pass bytes as title don't try to compare dicts don't compare int and string
author Christof Meerwald <cmeerw@cmeerw.org>
date Sat, 28 Jul 2018 22:01:46 +0100
parents 23b8e6067f7c
children 115efa91f7a1
comparison
equal deleted inserted replaced
5467:630a00b20394 5468:0cde8a595893
31 from roundup.cgi.templating import HTMLProperty, _HTMLItem, anti_csrf_nonce 31 from roundup.cgi.templating import HTMLProperty, _HTMLItem, anti_csrf_nonce
32 from roundup.cgi import client, actions 32 from roundup.cgi import client, actions
33 from roundup.cgi.engine_zopetal import RoundupPageTemplate 33 from roundup.cgi.engine_zopetal import RoundupPageTemplate
34 from roundup.cgi.templating import HTMLItem 34 from roundup.cgi.templating import HTMLItem
35 from roundup.exceptions import UsageError, Reject 35 from roundup.exceptions import UsageError, Reject
36
37 from roundup.anypy.strings import u2s
36 38
37 from .mocknull import MockNull 39 from .mocknull import MockNull
38 40
39 config = configuration.CoreConfig() 41 config = configuration.CoreConfig()
40 config.DATABASE = "db" 42 config.DATABASE = "db"
283 if commit: self.db.commit() 285 if commit: self.db.commit()
284 self.assertEqual(self.db.file.get(nid, 'content'), 'eggs') 286 self.assertEqual(self.db.file.get(nid, 'content'), 'eggs')
285 287
286 def testStringUnicode(self): 288 def testStringUnicode(self):
287 # test set & retrieve 289 # test set & retrieve
288 ustr = u'\xe4\xf6\xfc\u20ac'.encode('utf8') 290 ustr = u2s(u'\xe4\xf6\xfc\u20ac')
289 nid = self.db.issue.create(title=ustr, status='1') 291 nid = self.db.issue.create(title=ustr, status='1')
290 self.assertEqual(self.db.issue.get(nid, 'title'), ustr) 292 self.assertEqual(self.db.issue.get(nid, 'title'), ustr)
291 293
292 # change and make sure we retrieve the correct value 294 # change and make sure we retrieve the correct value
293 ustr2 = u'change \u20ac change'.encode('utf8') 295 ustr2 = u2s(u'change \u20ac change')
294 self.db.issue.set(nid, title=ustr2) 296 self.db.issue.set(nid, title=ustr2)
295 self.db.commit() 297 self.db.commit()
296 self.assertEqual(self.db.issue.get(nid, 'title'), ustr2) 298 self.assertEqual(self.db.issue.get(nid, 'title'), ustr2)
297 299
298 # Link 300 # Link
2306 # the integer part. 2308 # the integer part.
2307 for j in oj: 2309 for j in oj:
2308 j[1].second = float(int(j[1].second)) 2310 j[1].second = float(int(j[1].second))
2309 for j in rj: 2311 for j in rj:
2310 j[1].second = float(int(j[1].second)) 2312 j[1].second = float(int(j[1].second))
2311 oj.sort() 2313 oj.sort(key = lambda x: x[:4])
2312 rj.sort() 2314 rj.sort(key = lambda x: x[:4])
2313 ae(oj, rj) 2315 ae(oj, rj)
2314 2316
2315 # make sure the retired items are actually imported 2317 # make sure the retired items are actually imported
2316 ae(self.db.user.get('4', 'username'), 'blop') 2318 ae(self.db.user.get('4', 'username'), 'blop')
2317 ae(self.db.issue.get('2', 'title'), 'issue two') 2319 ae(self.db.issue.get('2', 'title'), 'issue two')
2318 2320
2319 # make sure id counters are set correctly 2321 # make sure id counters are set correctly
2320 maxid = max([int(id) for id in self.db.user.list()]) 2322 maxid = max([int(id) for id in self.db.user.list()])
2321 newid = self.db.user.create(username='testing') 2323 newid = int(self.db.user.create(username='testing'))
2322 assert newid > maxid 2324 assert newid > maxid
2323 2325
2324 # test import/export via admin interface 2326 # test import/export via admin interface
2325 def testAdminImportExport(self): 2327 def testAdminImportExport(self):
2326 import roundup.admin 2328 import roundup.admin

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