def setUp(self): """ Override the method setUp of TestCase. I cannot take this name better :( """ self.test_pomodoro = Timer()
class TestTimer(TestCase): """ Checks exclusively timer. """ def setUp(self): """ Override the method setUp of TestCase. I cannot take this name better :( """ self.test_pomodoro = Timer() def test_start(self): """ When call the function start the expected value is running = True """ time_left = 1500 returned = seconds_to_minutes(time_left) self.assertEqual((25, 0), returned) self.assertFalse(self.test_pomodoro.running) self.test_pomodoro.start() self.assertTrue(self.test_pomodoro.running) def test_pause(self): """ When call the function pause the expected value is running = False """ time_left = 1000 returned = seconds_to_minutes(time_left) self.assertEqual((16, 40), returned) self.test_pomodoro.pause() self.assertFalse(self.test_pomodoro.running) def test_update_running(self): """ When update is called with running = True the expected vale is time_left - 1 """ time_left = 900 returned = seconds_to_minutes(time_left) self.assertEqual((15, 0), returned) self.test_pomodoro.time_left = 12 self.test_pomodoro.running = True self.test_pomodoro.update() self.assertEqual(self.test_pomodoro.time_left, 11) def test_update_not_running(self): """ When update is called with running = False the expected vale is work_time """ time_left = 005 returned = seconds_to_minutes(time_left) self.assertEqual((0, 5), returned) work_time = 1500 self.test_pomodoro.running = False self.test_pomodoro.update() self.assertEqual(self.test_pomodoro.time_left, work_time) def test_update_running_and_not_time_left(self): ''' When rest timer ends time left starts again with work time ''' time_left = 900 returned = seconds_to_minutes(time_left) self.test_pomodoro.time_left = 0 self.test_pomodoro.running = True self.test_pomodoro.work_time = 500 self.test_pomodoro.update() self.assertEqual((15, 0), returned) self.assertEqual(self.test_pomodoro.time_left, 500)