charm-helpers
charm-helpers copied to clipboard
FAIL: test_check_restart_timestamps (tests.contrib.openstack.test_deferred_events.DeferredCharmServiceEventsTestCase)
running tox -e py38 fails with:
======================================================================
FAIL: test_check_restart_timestamps (tests.contrib.openstack.test_deferred_events.DeferredCharmServiceEventsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/freyes/Projects/charms/charm-helpers/.tox/py38/lib/python3.8/site-packages/mock.py", line 1201, in patched
return func(*args, **keywargs)
File "/home/freyes/Projects/charms/charm-helpers/tests/contrib/openstack/test_deferred_events.py", line 326, in test_check_restart_timestamps
self.assertFalse(clear_deferred_restarts.called)
AssertionError: True is not false
The test case uses the following timestamp https://github.com/juju/charm-helpers/blob/master/tests/contrib/openstack/test_deferred_events.py#L308-L310 which according to the comment it's expected to be interpreted as 'Tue 2021-02-02 10:19:55 UTC', the problem is that check_restart_timestamps() uses datetime.datetime.fromtimestamp() which will use the local timezone, I believe this line should be using datetime.datetime.utcfromtimestamp() instead or adjust the test fixture.
https://github.com/freyes/charm-helpers/blob/master/charmhelpers/contrib/openstack/deferred_events.py#L359