def test_sort_time_events(self): # Arrange event1 = TimeEvent("123", uuid4(), UNIX_EPOCH) event2 = TimeEvent("123", uuid4(), UNIX_EPOCH + timedelta(1)) # Act result = sorted([event2, event1]) # Assert self.assertEqual([event1, event2], result)
def test_equality(self): # Arrange event1 = TimeEvent("EVENT_1", UUID4(), 0, 0) event2 = TimeEvent("EVENT_1", UUID4(), 0, 0) event3 = TimeEvent("EVENT_2", UUID4(), 0, 0) # Act, Assert assert event1 == event1 assert event1 == event2 assert event1 != event3
def test_equality(self): # Arrange event1 = TimeEvent("EVENT_1", uuid4(), UNIX_EPOCH, 0, 0) event2 = TimeEvent("EVENT_1", uuid4(), UNIX_EPOCH, 0, 0) event3 = TimeEvent("EVENT_2", uuid4(), UNIX_EPOCH, 0, 0) # Act # Assert assert event1 == event1 assert event1 == event2 assert event1 != event3
def test_equality(self): # Arrange event1 = TimeEvent("EVENT_1", uuid4(), UNIX_EPOCH) event2 = TimeEvent("EVENT_1", uuid4(), UNIX_EPOCH) event3 = TimeEvent("EVENT_2", uuid4(), UNIX_EPOCH) # Act # Assert self.assertTrue(event1 == event1) self.assertTrue(event1 == event2) self.assertTrue(event1 != event3)
def test_sort(self): # Arrange receiver = [] event1 = TimeEventHandler(TimeEvent("123", UUID4(), 0, 0), receiver.append) event2 = TimeEventHandler(TimeEvent("123", UUID4(), 0, 0), receiver.append) event3 = TimeEventHandler(TimeEvent("123", UUID4(), 0, 0), receiver.append) # Act # Stable sort as event1 and event2 remain in order result = sorted([event3, event1, event2]) # Assert assert result == [event1, event2, event3]
def test_sort(self): # Arrange receiver = [] event1 = TimeEventHandler(TimeEvent("123", uuid4(), UNIX_EPOCH), receiver.append) event2 = TimeEventHandler(TimeEvent("123", uuid4(), UNIX_EPOCH), receiver.append) event3 = TimeEventHandler( TimeEvent("123", uuid4(), UNIX_EPOCH + timedelta(1)), receiver.append) # Act # Stable sort as event1 and event2 remain in order result = sorted([event3, event1, event2]) # Assert self.assertEqual([event1, event2, event3], result)
def test_comparisons(self): # Arrange receiver = [] event1 = TimeEventHandler(TimeEvent("123", uuid4(), UNIX_EPOCH), receiver.append) event2 = TimeEventHandler( TimeEvent("123", uuid4(), UNIX_EPOCH + timedelta(1)), receiver.append) # Act # Assert self.assertTrue(event1 == event1) self.assertTrue(event1 != event2) self.assertTrue(event1 < event2) self.assertTrue(event1 <= event2) self.assertTrue(event2 > event1) self.assertTrue(event2 >= event1)
def test_str_repr(self): # Arrange uuid = UUID4() event = TimeEvent("EVENT", uuid, 0, 0) # Act, Assert assert str(event) == (f"TimeEvent(name=EVENT, id={uuid})") assert repr(event) == (f"TimeEvent(name=EVENT, id={uuid})")
def test_hash_time_event(self): # Arrange event = TimeEvent("123", uuid4(), UNIX_EPOCH) # Act result = hash(event) # Assert self.assertEqual(int, type(result)) # No assertions raised
def test_str_repr(self): # Arrange uuid = uuid4() event = TimeEvent("EVENT", uuid, UNIX_EPOCH, 0, 0) # Act # Assert assert str(event) == (f"TimeEvent(name=EVENT, id={uuid}, " f"event_timestamp=1970-01-01T00:00:00.000Z)") assert repr(event) == (f"TimeEvent(name=EVENT, id={uuid}, " f"event_timestamp=1970-01-01T00:00:00.000Z)")
def test_str_repr(self): # Arrange uuid = uuid4() event = TimeEvent("EVENT", uuid, UNIX_EPOCH) # Act # Assert self.assertEqual( f"TimeEvent(name=EVENT, id={uuid}, timestamp=1970-01-01T00:00:00.000Z)", str(event)) # noqa self.assertEqual( f"TimeEvent(name=EVENT, id={uuid}, timestamp=1970-01-01T00:00:00.000Z)", repr(event)) # noqa
def test_str_repr(self): # Arrange receiver = [] uuid = UUID4() handler = TimeEventHandler(TimeEvent("123", uuid, 0, 0), receiver.append) print(str(handler)) # Act, Assert assert str(handler) == ( f"TimeEventHandler(event=TimeEvent(name=123, id={uuid}))") assert repr(handler) == ( f"TimeEventHandler(event=TimeEvent(name=123, id={uuid}))")
def test_str_repr(self): # Arrange receiver = [] uuid = uuid4() handler = TimeEventHandler(TimeEvent("123", uuid, UNIX_EPOCH), receiver.append) # Act # Assert self.assertEqual( f"TimeEventHandler(event=TimeEvent(name=123, id={uuid}, timestamp=1970-01-01T00:00:00.000Z))", str(handler)) # noqa self.assertEqual( f"TimeEventHandler(event=TimeEvent(name=123, id={uuid}, timestamp=1970-01-01T00:00:00.000Z))", repr(handler)) # noqa
def test_str_repr(self): # Arrange receiver = [] uuid = uuid4() handler = TimeEventHandler(TimeEvent("123", uuid, UNIX_EPOCH, 0, 0), receiver.append) print(str(handler)) # Act # Assert assert str(handler) == ( f"TimeEventHandler(event=TimeEvent(name=123, id={uuid}, " f"event_timestamp=1970-01-01T00:00:00.000Z))") assert repr(handler) == ( f"TimeEventHandler(event=TimeEvent(name=123, id={uuid}, " f"event_timestamp=1970-01-01T00:00:00.000Z))")
def test_comparisons(self): # Arrange receiver = [] event1 = TimeEventHandler(TimeEvent("123", uuid4(), UNIX_EPOCH, 0, 0), receiver.append) event2 = TimeEventHandler( TimeEvent( "123", uuid4(), UNIX_EPOCH + timedelta(seconds=1), 1_000_000_000, 0, ), receiver.append, ) # Act # Assert assert event1 == event1 assert event1 != event2 assert event1 < event2 assert event1 <= event2 assert event2 > event1 assert event2 >= event1
def test_comparisons(self): # Arrange receiver = [] event1 = TimeEventHandler( TimeEvent("123", UUID4(), 0, 0), receiver.append, ) event2 = TimeEventHandler( TimeEvent( "123", UUID4(), 1_000_000_000, 0, ), receiver.append, ) # Act, Assert assert event1 == event1 assert event1 != event2 assert event1 < event2 assert event1 <= event2 assert event2 > event1 assert event2 >= event1