Added test_public_mode

This commit is contained in:
Micah Lee 2019-11-09 00:42:49 +08:00
parent 1e98ccb696
commit eff5fb1c4a
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 20 additions and 12 deletions

View File

@ -114,6 +114,8 @@ class GuiBaseTest(unittest.TestCase):
def close_all_tabs(self):
for _ in range(self.gui.tabs.count()):
tab = self.gui.tabs.widget(0)
QtCore.QTimer.singleShot(0, tab.close_dialog.accept_button.click)
self.gui.tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide).click()
def gui_loaded(self):
@ -307,16 +309,6 @@ class GuiBaseTest(unittest.TestCase):
"""Test that the counter has incremented"""
self.assertEqual(tab.get_mode().history.completed_count, count)
def stop_running_server(self, tab):
"""Stop a server that's running"""
self.assertNotEqual(tab.get_mode().server_status.status, 0)
tab.get_mode().server_status.server_button.click()
QtTest.QTest.qWait(200)
self.server_is_stopped(tab)
self.web_server_is_stopped(tab)
def server_is_stopped(self, tab):
"""Test that the server stops when we click Stop"""
if (
@ -348,7 +340,7 @@ class GuiBaseTest(unittest.TestCase):
strings._("gui_status_indicator_receive_stopped"),
)
if type(tab.get_mode()) == ShareMode:
if tab.settings.get("share", "autostop_sharing"):
if not tab.settings.get("share", "autostop_sharing"):
self.assertEqual(
tab.get_mode().server_status_label.text(),
strings._("gui_status_indicator_share_stopped"),

View File

@ -114,6 +114,8 @@ class TestShare(GuiBaseTest):
QtTest.QTest.qWait(50)
self.assertEqual("onionshare", zip.read("test.txt").decode("utf-8"))
QtTest.QTest.qWait(500)
def individual_file_is_viewable_or_not(self, tab):
"""
Test that an individual file is viewable (when in autostop_sharing is false) or that it
@ -402,7 +404,6 @@ class TestShare(GuiBaseTest):
self.scheduled_service_started(tab, 2200)
self.web_server_is_running(tab)
self.stop_running_server(tab)
self.close_all_tabs()
@pytest.mark.gui
@ -455,3 +456,18 @@ class TestShare(GuiBaseTest):
self.run_all_common_setup_tests()
self.run_all_clear_all_button_tests(tab)
self.close_all_tabs()
@pytest.mark.gui
def test_public_mode(self):
"""
Public mode shouldn't have a password
"""
tab = self.new_share_tab()
tab.get_mode().mode_settings_widget.public_checkbox.click()
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(tab)
self.close_all_tabs()