From 29ebdd850eb1a71183c7c4c9dbd9eb85b1eaefd4 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Fri, 8 Nov 2019 20:06:24 +0800 Subject: [PATCH] Start adding test_autostart_timer --- tests2/gui_base_test.py | 4 ++++ tests2/test_gui_share.py | 37 +++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/tests2/gui_base_test.py b/tests2/gui_base_test.py index 85f7672d..77aa65bd 100644 --- a/tests2/gui_base_test.py +++ b/tests2/gui_base_test.py @@ -109,6 +109,10 @@ class GuiBaseTest(unittest.TestCase): return tab + def close_all_tabs(self): + for _ in range(self.gui.tabs.count()): + self.gui.tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide).click() + def gui_loaded(self): """Test that the GUI actually is shown""" self.assertTrue(self.gui.show) diff --git a/tests2/test_gui_share.py b/tests2/test_gui_share.py index 412367d0..c8a7ebba 100644 --- a/tests2/test_gui_share.py +++ b/tests2/test_gui_share.py @@ -200,7 +200,7 @@ class TestShare(GuiBaseTest): schedule, ) - def autostart_timer_widget_hidden(self, tab, mode): + def autostart_timer_widget_hidden(self, tab): """Test that the auto-start timer widget is hidden when share has started""" self.assertFalse( tab.get_mode().mode_settings_widget.autostart_timer_widget.isVisible() @@ -336,17 +336,6 @@ class TestShare(GuiBaseTest): self.server_timed_out(tab, 10000) self.web_server_is_stopped(tab) - def run_all_share_mode_autostart_timer_tests(self, tab): - """Auto-start timer tests in share mode""" - self.run_all_share_mode_setup_tests(tab) - self.set_autostart_timer(tab, 5) - self.server_working_on_start_button_pressed(tab) - self.autostart_timer_widget_hidden(tab) - self.server_status_indicator_says_scheduled(tab) - self.web_server_is_stopped(tab) - self.scheduled_service_started(tab, 7000) - self.web_server_is_running(tab) - def run_all_share_mode_unreadable_file_tests(self, tab): """Attempt to share an unreadable file""" self.run_all_share_mode_setup_tests(tab) @@ -360,6 +349,9 @@ class TestShare(GuiBaseTest): @pytest.mark.gui def test_autostart_and_autostop_timer_mismatch(self): + """ + If autostart timer is after autostop timer, a warning should be thrown + """ tab = self.new_share_tab() def accept_dialog(): @@ -379,3 +371,24 @@ class TestShare(GuiBaseTest): QtCore.QTimer.singleShot(200, accept_dialog) tab.get_mode().server_status.server_button.click() self.server_is_stopped(tab) + + self.close_all_tabs() + + @pytest.mark.gui + def test_autostart_timer(self): + """ + Autostart timer should automatically start + """ + tab = self.new_share_tab() + self.run_all_common_setup_tests() + + self.run_all_share_mode_setup_tests(tab) + self.set_autostart_timer(tab, 5) + self.server_working_on_start_button_pressed(tab) + self.autostart_timer_widget_hidden(tab) + self.server_status_indicator_says_scheduled(tab) + self.web_server_is_stopped(tab) + self.scheduled_service_started(tab, 7000) + self.web_server_is_running(tab) + + self.close_all_tabs()