From 9ae98eb7cb64b83dcaaf2c063bda327cb068b0ce Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Tue, 3 Sep 2019 12:23:27 +1000 Subject: [PATCH] Extend coverage of website mode tests --- tests/GuiBaseTest.py | 5 ++++- tests/GuiShareTest.py | 9 ++------- tests/GuiWebsiteTest.py | 7 +++++-- tests/TorGuiShareTest.py | 2 +- tests/local_onionshare_website_mode_test.py | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/GuiBaseTest.py b/tests/GuiBaseTest.py index d2a43362..f478dd94 100644 --- a/tests/GuiBaseTest.py +++ b/tests/GuiBaseTest.py @@ -202,6 +202,9 @@ class GuiBaseTest(object): else: self.assertIsNone(mode.server_status.web.password, r'(\w+)-(\w+)') + def add_button_visible(self, mode): + '''Test that the add button should be visible''' + self.assertTrue(mode.server_status.file_selection.add_button.isVisible()) def url_description_shown(self, mode): '''Test that the URL label is showing''' @@ -253,7 +256,7 @@ class GuiBaseTest(object): def server_is_stopped(self, mode, stay_open): '''Test that the server stops when we click Stop''' - if type(mode) == ReceiveMode or (type(mode) == ShareMode and stay_open): + if type(mode) == ReceiveMode or (type(mode) == ShareMode and stay_open) or (type(mode) == WebsiteMode): QtTest.QTest.mouseClick(mode.server_status.server_button, QtCore.Qt.LeftButton) self.assertEqual(mode.server_status.status, 0) diff --git a/tests/GuiShareTest.py b/tests/GuiShareTest.py index b6f50a28..34573a19 100644 --- a/tests/GuiShareTest.py +++ b/tests/GuiShareTest.py @@ -130,11 +130,6 @@ class GuiShareTest(GuiBaseTest): self.web_server_is_stopped() - def add_button_visible(self): - '''Test that the add button should be visible''' - self.assertTrue(self.gui.share_mode.server_status.file_selection.add_button.isVisible()) - - # 'Grouped' tests follow from here def run_all_share_mode_setup_tests(self): @@ -171,7 +166,7 @@ class GuiShareTest(GuiBaseTest): self.server_is_stopped(self.gui.share_mode, stay_open) self.web_server_is_stopped() self.server_status_indicator_says_closed(self.gui.share_mode, stay_open) - self.add_button_visible() + self.add_button_visible(self.gui.share_mode) self.server_working_on_start_button_pressed(self.gui.share_mode) self.server_is_started(self.gui.share_mode) self.history_indicator(self.gui.share_mode, public_mode) @@ -184,7 +179,7 @@ class GuiShareTest(GuiBaseTest): self.server_is_stopped(self.gui.share_mode, stay_open) self.web_server_is_stopped() self.server_status_indicator_says_closed(self.gui.share_mode, stay_open) - self.add_button_visible() + self.add_button_visible(self.gui.share_mode) self.server_working_on_start_button_pressed(self.gui.share_mode) self.server_is_started(self.gui.share_mode) self.history_indicator(self.gui.share_mode, public_mode) diff --git a/tests/GuiWebsiteTest.py b/tests/GuiWebsiteTest.py index 6697c5b9..7b88bfdf 100644 --- a/tests/GuiWebsiteTest.py +++ b/tests/GuiWebsiteTest.py @@ -54,7 +54,6 @@ class GuiWebsiteTest(GuiShareTest): except: pass - def view_website(self, public_mode): '''Test that we can download the share''' url = "http://127.0.0.1:{}/".format(self.gui.app.port) @@ -88,10 +87,14 @@ class GuiWebsiteTest(GuiShareTest): self.server_status_indicator_says_started(self.gui.website_mode) - def run_all_website_mode_download_tests(self, public_mode, stay_open): + def run_all_website_mode_download_tests(self, public_mode): """Tests in website mode after viewing the site""" self.run_all_website_mode_setup_tests() self.run_all_website_mode_started_tests(public_mode, startup_time=2000) self.view_website(public_mode) self.history_widgets_present(self.gui.website_mode) + self.server_is_stopped(self.gui.website_mode, False) + self.web_server_is_stopped() + self.server_status_indicator_says_closed(self.gui.website_mode, False) + self.add_button_visible(self.gui.website_mode) diff --git a/tests/TorGuiShareTest.py b/tests/TorGuiShareTest.py index 352707eb..cfce9d4e 100644 --- a/tests/TorGuiShareTest.py +++ b/tests/TorGuiShareTest.py @@ -67,7 +67,7 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest): self.server_is_stopped(self.gui.share_mode, stay_open) self.web_server_is_stopped() self.server_status_indicator_says_closed(self.gui.share_mode, stay_open) - self.add_button_visible() + self.add_button_visible(self.gui.share_mode) self.server_working_on_start_button_pressed(self.gui.share_mode) self.server_is_started(self.gui.share_mode, startup_time=45000) self.history_indicator(self.gui.share_mode, public_mode) diff --git a/tests/local_onionshare_website_mode_test.py b/tests/local_onionshare_website_mode_test.py index 5a6dc10f..051adb3c 100644 --- a/tests/local_onionshare_website_mode_test.py +++ b/tests/local_onionshare_website_mode_test.py @@ -19,7 +19,7 @@ class LocalWebsiteModeTest(unittest.TestCase, GuiWebsiteTest): @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest") def test_gui(self): #self.run_all_common_setup_tests() - self.run_all_website_mode_download_tests(False, False) + self.run_all_website_mode_download_tests(False) if __name__ == "__main__": unittest.main()