Skip to content

Commit

Permalink
fixup! Add start of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Aug 22, 2023
1 parent 281fa84 commit a8a7305
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_zinolib_event_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ def test_get_downtime_should_fail_noisily_on_non_PortStateEvent(self):
with self.assertRaises(AttributeError):
event.get_downtime()

def test_ac_down_field_should_be_timedelta(self):
# pydantic changes its mind as to what formats are supported
# so we double check here
minimal_input = common_minimal_input.copy()
minimal_input.update(**{
"type": Event.Type.REACHABILITY,
"reachability": "fjgh",
"ac_down": 4564654,
})
event = Event.create(minimal_input)
self.assertTrue(isinstance(event.ac_down, timedelta))

def test_lasttrans_and_updated_should_be_datetime(self):
# pydantic changes its mind as to what formats are supported
# so we double check here
input = common_minimal_input.copy()
input.update(**{
"type": Event.Type.REACHABILITY,
"reachability": "fjgh",
"ac_down": 4564654,
"lasttrans": "1234567890",
"updated": "1234567890",
})
event = Event.create(input)
self.assertTrue(isinstance(event.lasttrans, datetime))
self.assertTrue(isinstance(event.updated, datetime))


class AlarmEventTest(unittest.TestCase):

Expand Down

0 comments on commit a8a7305

Please sign in to comment.