From 4d7ed41602a9484a994c9fb83e205356ff4ed13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 10 Apr 2020 14:54:47 +0200 Subject: [PATCH] fix: Properly handle timezone in tests --- tests/testlive_comprehensive.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index fd3942b..896c8b5 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -2081,7 +2081,6 @@ class TestComprehensive(unittest.TestCase): self.admin_misp_connector.delete_event(second) def test_first_last_seen(self): - local_tz = datetime.now(timezone.utc).astimezone().tzinfo event = MISPEvent() event.info = 'Test First Last seen' event.add_attribute('ip-dst', '8.8.8.8', first_seen='2020-01-04', last_seen='2020-01-04T12:30:34.323242+0800') @@ -2092,7 +2091,7 @@ class TestComprehensive(unittest.TestCase): try: first = self.admin_misp_connector.add_event(event, pythonify=True) # Simple attribute - self.assertEqual(first.attributes[0].first_seen, datetime(2020, 1, 4, 0, 0, tzinfo=local_tz)) + self.assertEqual(first.attributes[0].first_seen, datetime(2020, 1, 4, 0, 0).astimezone()) self.assertEqual(first.attributes[0].last_seen, datetime(2020, 1, 4, 4, 30, 34, 323242, tzinfo=timezone.utc)) # Object @@ -2100,8 +2099,8 @@ class TestComprehensive(unittest.TestCase): self.assertEqual(first.objects[0].last_seen, datetime(2020, 1, 27, 17, 48, 20, tzinfo=timezone.utc)) # Object attribute - self.assertEqual(first.objects[0].attributes[0].first_seen, datetime(2022, 1, 30, 0, 0, tzinfo=local_tz)) - self.assertEqual(first.objects[0].attributes[0].last_seen, datetime(2022, 2, 23, 0, 0, tzinfo=local_tz)) + self.assertEqual(first.objects[0].attributes[0].first_seen, datetime(2022, 1, 30, 0, 0).astimezone()) + self.assertEqual(first.objects[0].attributes[0].last_seen, datetime(2022, 2, 23, 0, 0).astimezone()) # Update values # Attribute in full event