Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
    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)
Beispiel #4
0
    def test_end_is_idempotent(self):
        chk_point = Checkpoint(Point.checkin)
        chk_point.start()
        chk_point.end()
        date1 = chk_point.ended_at
        chk_point.end()
        date2 = chk_point.ended_at

        self.assertEqual(date1, date2)
Beispiel #5
0
 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'))
Beispiel #6
0
 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)
Beispiel #7
0
 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)
Beispiel #8
0
 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'))
Beispiel #9
0
 def test_type_must_be_known(self):
     chk_point = Checkpoint(Point.checkin)
     self.assertIsInstance(chk_point, Checkpoint)
Beispiel #10
0
    def test_unknown_type_raises_ValueError(self):
        class Color(enum.Enum):
            red = 1

        self.assertRaises(ValueError, lambda: Checkpoint(Color.red))
Beispiel #11
0
 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)
Beispiel #12
0
 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)
Beispiel #13
0
 def test_is_active_returns_True_after_start(self):
     chk_point = Checkpoint(Point.checkin)
     chk_point.start()
     self.assertEqual(chk_point.is_active, True)
Beispiel #14
0
 def test_end_before_start_raises_RuntimeError(self):
     chk_point = Checkpoint(Point.checkin)
     self.assertRaises(RuntimeError, lambda: chk_point.end())
Beispiel #15
0
 def test_non_enum_type_raises_ValueError(self):
     self.assertRaises(ValueError, lambda: Checkpoint('foo'))
Beispiel #16
0
    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)
Beispiel #17
0
 def test_neutral_initial_state(self):
     chk_point = Checkpoint(Point.checkin)
     self.assertEqual(chk_point.started_at, None)
     self.assertEqual(chk_point.ended_at, None)
Beispiel #18
0
    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)
Beispiel #19
0
 def test_end_before_start_raises_RuntimeError(self):
     chk_point = Checkpoint(Point.checkin)
     self.assertRaises(RuntimeError, lambda: chk_point.end())
Beispiel #20
0
 def test_is_active_returns_True_after_start(self):
     chk_point = Checkpoint(Point.checkin)
     chk_point.start()
     self.assertEqual(chk_point.is_active, True)
Beispiel #21
0
 def test_is_active_returns_False_on_initial_state(self):
     chk_point = Checkpoint(Point.checkin)
     self.assertEqual(chk_point.is_active, False)