Fixing test bug

This commit is contained in:
M1ha 2019-06-28 13:33:22 +05:00
parent 8b9e2332db
commit 37712b4156
2 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,6 @@ def format_datetime(dt, timezone_offset=0, day_end=False, db_alias=None):
# Dates in ClickHouse are parsed in server local timezone. So I need to add server timezone
server_dt = dt - datetime.timedelta(minutes=timezone_offset - get_tz_offset(db_alias))
print(dt, timezone_offset, get_tz_offset(db_alias))
return server_dt.strftime("%Y-%m-%d %H:%M:%S")

View File

@ -41,7 +41,8 @@ class FormatDateTimeTest(TestCase):
self.assertEqual(format_datetime(dt), self._get_zone_time(dt))
dt = datetime.datetime(2017, 1, 2, 3, 4, 5, tzinfo=pytz.timezone('Europe/Moscow'))
offset = int(pytz.timezone('Europe/Moscow').utcoffset(dt).total_seconds() / 60)
self.assertEqual(format_datetime(dt, timezone_offset=offset), '2017-01-02 03:04:05')
self.assertEqual(format_datetime(dt, timezone_offset=offset),
local_dt_str(datetime.datetime(2017, 1, 2, 3, 4, 5) - datetime.timedelta(minutes=offset*2)))
def test_date_conversion(self):
dt = datetime.date(2017, 1, 2)