mirror of https://github.com/MISP/PyMISP
fix: Tests failing if local tz was not CET
parent
a8ff8f88fe
commit
7e29d41976
|
@ -2079,10 +2079,10 @@ class TestComprehensive(unittest.TestCase):
|
||||||
self.admin_misp_connector.delete_event(second)
|
self.admin_misp_connector.delete_event(second)
|
||||||
|
|
||||||
def test_first_last_seen(self):
|
def test_first_last_seen(self):
|
||||||
|
local_tz = datetime.now(timezone.utc).astimezone().tzinfo
|
||||||
event = MISPEvent()
|
event = MISPEvent()
|
||||||
event.info = 'Test First Last seen'
|
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')
|
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)
|
obj = event.add_object(name='file', first_seen=1580147259.268763, last_seen=1580147300)
|
||||||
attr = obj.add_attribute('filename', 'blah.exe')
|
attr = obj.add_attribute('filename', 'blah.exe')
|
||||||
attr.first_seen = '2022-01-30'
|
attr.first_seen = '2022-01-30'
|
||||||
|
@ -2090,7 +2090,7 @@ class TestComprehensive(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
first = self.admin_misp_connector.add_event(event, pythonify=True)
|
first = self.admin_misp_connector.add_event(event, pythonify=True)
|
||||||
# Simple attribute
|
# 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))
|
self.assertEqual(first.attributes[0].last_seen, datetime(2020, 1, 4, 4, 30, 34, 323242, tzinfo=timezone.utc))
|
||||||
|
|
||||||
# Object
|
# 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))
|
self.assertEqual(first.objects[0].last_seen, datetime(2020, 1, 27, 17, 48, 20, tzinfo=timezone.utc))
|
||||||
|
|
||||||
# Object attribute
|
# 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].first_seen, datetime(2022, 1, 30, 0, 0, tzinfo=local_tz))
|
||||||
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].last_seen, datetime(2022, 2, 23, 0, 0, tzinfo=local_tz))
|
||||||
|
|
||||||
# Update values
|
# Update values
|
||||||
# Attribute in full event
|
# Attribute in full event
|
||||||
|
|
Loading…
Reference in New Issue