class TestUI(TestCase): """ Checks exclusively user interface. """ def setUp(self): self.timer = Timer() self.UI = UI(self.timer) def test_function_init(self): ''' After init the menu and quit item exists and current status has to be 0 ''' self.assertEqual(self.UI.current_status, 0) self.assertTrue(self.UI.menu) self.assertTrue(self.UI.quit_item) def test_start_timer(self): ''' Start timer sets current status = 0 ''' current_status = 0 self.UI.start_timer() self.assertEqual(current_status, self.UI.current_status) def test_rest_icon_with_status_1(self): ''' When status = 1 rest icon has to be displayed ''' self.UI.current_status = 1 self.UI._set_icon() self.assertEqual(self.UI.status_icon.get_title(), 'rest.png') def test_work_icon_with_status_0(self): ''' When status = 0 work icon has to be displayed ''' self.UI.current_status = 0 self.UI._set_icon() self.assertEqual(self.UI.status_icon.get_title(), 'work.png') def test_correct_label_being_shown(self): ''' Asserts the label being shown is the label passed ''' string = 'Just testing' self.UI._set_label(string) self.assertEqual(self.UI.label.get_label(), string) def test_pause_timer_changes_status(self): ''' Assert status changes when call pause timer ''' self.UI.current_status = 0 self.UI.pause_timer() self.assertEqual(self.UI.current_status, 1) def test_update_timer_changes_status_icon(self): ''' Update timer has to the change the icon work/rest ''' self.UI.current_status = 0 self.timer.time_left = 15 self.UI.update_timer() tooltip_text = self.UI.status_icon.get_tooltip_text() self.assertTrue(tooltip_text.startswith('Pomodoro4linux')) def test_update_timer_changes_label_str(self): ''' Label of the dialog has to change when the work timer is over ''' self.UI.current_status = 1 self.timer.time_left = 15 self.UI.update_timer() label_str = self.UI.label.get_label() self.assertTrue(label_str.startswith('Coffee Break')) def test_update_timer_sets_the_dialog_visible(self): ''' Update timer sets the dialog visible when needed ''' self.UI.current_status = 0 self.timer.time_left = 0 self.UI.update_timer() self.assertTrue(self.UI.dialog.get_visible) def test_update_timer_changes_label_str_to_work(self): ''' Label of the dialog has to change when the rest timer is over ''' self.UI.current_status = 1 self.timer.time_left = 0 self.UI.update_timer() label_str = self.UI.label.get_label() self.assertTrue(label_str.startswith('You should'))
class TestUI(TestCase): """ Checks exclusively user interface. """ def setUp(self): self.timer = Timer() self.UI = UI(self.timer) def test_function_init(self): ''' After init the menu and quit item exists and current status has to be 0 ''' self.assertEqual(self.UI.current_status, 0) self.assertTrue(self.UI.menu) self.assertTrue(self.UI.quit_item) def test_start_timer(self): ''' Start timer sets current status = 0 ''' current_status = 0 self.UI.start_timer() self.assertEqual(current_status, self.UI.current_status) def test_rest_icon_with_status_1(self): ''' When status = 1 rest icon has to be displayed ''' self.UI.current_status = 1 self.UI._set_icon() self.assertEqual(self.UI.status_icon.get_title(), 'rest.png') def test_work_icon_with_status_0(self): ''' When status = 0 work icon has to be displayed ''' self.UI.current_status = 0 self.UI._set_icon() self.assertEqual(self.UI.status_icon.get_title(), 'work.png') def test_pause_timer_changes_status(self): ''' Assert status changes when call pause timer ''' self.UI.current_status = 0 self.UI.pause_timer() self.assertEqual(self.UI.current_status, 1) def test_update_timer_changes_status_icon(self): ''' Update timer has to the change the icon work/rest ''' self.UI.current_status = 0 self.timer.time_left = 15 self.UI.update_timer() tooltip_text = self.UI.status_icon.get_tooltip_text() self.assertTrue(tooltip_text.startswith('Pomodoro4linux')) def test_update_timer_sets_the_dialog_visible(self): ''' Update timer sets the dialog visible when needed ''' self.UI.current_status = 0 self.timer.time_left = 0 self.UI.update_timer() self.assertTrue(self.UI.dialog.get_visible)