From 7e29d419765194b50046496adac73ac580884d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 28 Jan 2020 16:30:58 +0100 Subject: [PATCH] fix: Tests failing if local tz was not CET --- tests/testlive_comprehensive.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 58ca558..3f8dc67 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -2079,10 +2079,10 @@ 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+8:00') - print(event.attributes) obj = event.add_object(name='file', first_seen=1580147259.268763, last_seen=1580147300) attr = obj.add_attribute('filename', 'blah.exe') attr.first_seen = '2022-01-30' @@ -2090,7 +2090,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, 3, 23, 0, tzinfo=timezone.utc)) + self.assertEqual(first.attributes[0].first_seen, datetime(2020, 1, 4, 0, 0, tzinfo=local_tz)) self.assertEqual(first.attributes[0].last_seen, datetime(2020, 1, 4, 4, 30, 34, 323242, tzinfo=timezone.utc)) # Object @@ -2098,8 +2098,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, 29, 23, 0, tzinfo=timezone.utc)) - self.assertEqual(first.objects[0].attributes[0].last_seen, datetime(2022, 2, 22, 23, 0, tzinfo=timezone.utc)) + 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)) # Update values # Attribute in full event