def test_tell_store_messages_based_on_labels(self): chk_point = Checkpoint(Point.checkin) chk_point.start() chk_point.tell('Foo', Status.ok, label='zip') self.assertEqual(chk_point.messages[0].label, 'zip') self.assertEqual(chk_point.messages[0].message, 'Foo') self.assertEqual(chk_point.messages[0].status, Status.ok)
def test_tell_raises_RuntimeError_on_inactive_objects(self): chk_point = Checkpoint(Point.checkin) chk_point.start() chk_point.end() self.assertRaises( RuntimeError, lambda: chk_point.tell('Foo', Status.ok, label='zip'))
def test_tell_store_messages(self): chk_point = Checkpoint(Point.checkin) chk_point.start() chk_point.tell('Foo', Status.ok) self.assertEqual(chk_point.messages[0].label, None) self.assertEqual(chk_point.messages[0].message, 'Foo') self.assertEqual(chk_point.messages[0].status, Status.ok)
def test_start_is_idempotent(self): chk_point = Checkpoint(Point.checkin) chk_point.start() date1 = chk_point.started_at chk_point.start() date2 = chk_point.started_at self.assertEqual(date1, date2)
def test_is_active_returns_False_after_end(self): chk_point = Checkpoint(Point.checkin) chk_point.start() chk_point.end() self.assertEqual(chk_point.is_active, False)
def test_is_active_returns_True_after_start(self): chk_point = Checkpoint(Point.checkin) chk_point.start() self.assertEqual(chk_point.is_active, True)
def test_ended_at_is_filled_on_end(self): chk_point = Checkpoint(Point.checkin) chk_point.start() chk_point.end() self.assertIsInstance(chk_point.ended_at, datetime)
def test_tell_raises_RuntimeError_on_inactive_objects(self): chk_point = Checkpoint(Point.checkin) chk_point.start() chk_point.end() self.assertRaises(RuntimeError, lambda: chk_point.tell('Foo', Status.ok, label='zip'))