Commit d5b607fa authored by Ivan Tyagov's avatar Ivan Tyagov

Fix test to take into account timezone (see r17867 - r17870).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17872 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e97fef23
...@@ -562,17 +562,20 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -562,17 +562,20 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
module = portal.getDefaultModule('Organisation') module = portal.getDefaultModule('Organisation')
organisation = module.newContent(portal_type='Organisation',) organisation = module.newContent(portal_type='Organisation',)
creation_date = organisation.getCreationDate().ISO() creation_date = organisation.getCreationDate().toZone('UTC').ISO()
modification_date = organisation.getModificationDate().toZone('UTC').ISO()
get_transaction().commit() get_transaction().commit()
now = DateTime() now = DateTime()
self.tic() self.tic()
sql = """select creation_date, modification_date sql = """select creation_date, modification_date
from catalog where uid = %s""" % organisation.getUid() from catalog where uid = %s""" % organisation.getUid()
result = sql_connection.manage_test(sql) result = sql_connection.manage_test(sql)
self.assertEquals(creation_date, result[0]['creation_date'].ISO()) self.assertEquals(creation_date,
self.assertEquals(organisation.getModificationDate().ISO(), result[0]['creation_date'].ISO())
self.assertEquals(modification_date,
result[0]['modification_date'].ISO())
self.assertEquals(creation_date,
result[0]['modification_date'].ISO()) result[0]['modification_date'].ISO())
self.assertEquals(creation_date, result[0]['modification_date'].ISO())
import time; time.sleep(3) import time; time.sleep(3)
organisation.edit(title='edited') organisation.edit(title='edited')
...@@ -580,12 +583,13 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -580,12 +583,13 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.tic() self.tic()
result = sql_connection.manage_test(sql) result = sql_connection.manage_test(sql)
self.assertEquals(creation_date, result[0]['creation_date'].ISO()) self.assertEquals(creation_date, result[0]['creation_date'].ISO())
self.assertNotEquals(organisation.getModificationDate(), modification_date = organisation.getModificationDate().toZone('UTC').ISO()
self.assertNotEquals(modification_date,
organisation.getCreationDate()) organisation.getCreationDate())
# This test was first written with a now variable initialized with # This test was first written with a now variable initialized with
# DateTime(). But since we are never sure of the time required in # DateTime(). But since we are never sure of the time required in
# order to execute some line of code # order to execute some line of code
self.assertEquals(organisation.getModificationDate().ISO(), self.assertEquals(modification_date,
result[0]['modification_date'].ISO()) result[0]['modification_date'].ISO())
self.assertTrue(organisation.getModificationDate()>now) self.assertTrue(organisation.getModificationDate()>now)
self.assertTrue(result[0]['creation_date']<result[0]['modification_date']) self.assertTrue(result[0]['creation_date']<result[0]['modification_date'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment