2019-11-08 03:20:38 -05:00
|
|
|
import pytest
|
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
import tempfile
|
2019-11-08 06:11:30 -05:00
|
|
|
import zipfile
|
2019-11-08 03:20:38 -05:00
|
|
|
|
2019-11-08 03:57:50 -05:00
|
|
|
from PyQt5 import QtCore, QtTest
|
2019-11-08 03:20:38 -05:00
|
|
|
|
|
|
|
from .gui_base_test import GuiBaseTest
|
|
|
|
|
|
|
|
|
|
|
|
class TestShare(GuiBaseTest):
|
|
|
|
# Shared test methods
|
|
|
|
|
|
|
|
# Persistence tests
|
2019-11-08 06:11:30 -05:00
|
|
|
def have_same_password(self, tab, password):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test that we have the same password"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.assertEqual(tab.get_mode().server_status.web.password, password)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
|
|
|
# Share-specific tests
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def file_selection_widget_has_files(self, tab, num=2):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test that the number of items in the list is as expected"""
|
|
|
|
self.assertEqual(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.get_num_files(), num
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def deleting_all_files_hides_delete_button(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test that clicking on the file item shows the delete button. Test that deleting the only item in the list hides the delete button"""
|
2019-11-08 06:11:30 -05:00
|
|
|
rect = tab.get_mode().server_status.file_selection.file_list.visualItemRect(
|
|
|
|
tab.get_mode().server_status.file_selection.file_list.item(0)
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
QtTest.QTest.mouseClick(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.viewport(),
|
2019-11-08 03:20:38 -05:00
|
|
|
QtCore.Qt.LeftButton,
|
|
|
|
pos=rect.center(),
|
|
|
|
)
|
|
|
|
# Delete button should be visible
|
|
|
|
self.assertTrue(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.delete_button.isVisible()
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
# Click delete, delete button should still be visible since we have one more file
|
|
|
|
QtTest.QTest.mouseClick(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.delete_button,
|
2019-11-08 03:20:38 -05:00
|
|
|
QtCore.Qt.LeftButton,
|
|
|
|
)
|
2019-11-08 06:11:30 -05:00
|
|
|
rect = tab.get_mode().server_status.file_selection.file_list.visualItemRect(
|
|
|
|
tab.get_mode().server_status.file_selection.file_list.item(0)
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
QtTest.QTest.mouseClick(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.viewport(),
|
2019-11-08 03:20:38 -05:00
|
|
|
QtCore.Qt.LeftButton,
|
|
|
|
pos=rect.center(),
|
|
|
|
)
|
|
|
|
self.assertTrue(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.delete_button.isVisible()
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
QtTest.QTest.mouseClick(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.delete_button,
|
2019-11-08 03:20:38 -05:00
|
|
|
QtCore.Qt.LeftButton,
|
|
|
|
)
|
|
|
|
|
|
|
|
# No more files, the delete button should be hidden
|
|
|
|
self.assertFalse(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.delete_button.isVisible()
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def add_a_file_and_delete_using_its_delete_widget(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test that we can also delete a file by clicking on its [X] widget"""
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[0])
|
2019-11-08 03:20:38 -05:00
|
|
|
QtTest.QTest.mouseClick(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.item(0).item_button,
|
2019-11-08 03:20:38 -05:00
|
|
|
QtCore.Qt.LeftButton,
|
|
|
|
)
|
2019-11-08 06:11:30 -05:00
|
|
|
self.file_selection_widget_has_files(tab, 0)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def file_selection_widget_read_files(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Re-add some files to the list so we can share"""
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[0])
|
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[1])
|
|
|
|
self.file_selection_widget_has_files(tab, 2)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def add_large_file(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Add a large file to the share"""
|
|
|
|
size = 1024 * 1024 * 155
|
|
|
|
with open("/tmp/large_file", "wb") as fout:
|
|
|
|
fout.write(os.urandom(size))
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(
|
2019-11-08 03:20:38 -05:00
|
|
|
"/tmp/large_file"
|
|
|
|
)
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def add_delete_buttons_hidden(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test that the add and delete buttons are hidden when the server starts"""
|
|
|
|
self.assertFalse(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.add_button.isVisible()
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
self.assertFalse(
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.delete_button.isVisible()
|
2019-11-08 03:20:38 -05:00
|
|
|
)
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def download_share(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test that we can download the share"""
|
2019-11-08 06:11:30 -05:00
|
|
|
url = f"http://127.0.0.1:{tab.app.port}/download"
|
|
|
|
if tab.settings.get("general", "public"):
|
2019-11-08 03:20:38 -05:00
|
|
|
r = requests.get(url)
|
|
|
|
else:
|
|
|
|
r = requests.get(
|
|
|
|
url,
|
|
|
|
auth=requests.auth.HTTPBasicAuth(
|
2019-11-08 06:11:30 -05:00
|
|
|
"onionshare", tab.get_mode().server_status.web.password
|
2019-11-08 03:20:38 -05:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
tmp_file = tempfile.NamedTemporaryFile()
|
|
|
|
with open(tmp_file.name, "wb") as f:
|
|
|
|
f.write(r.content)
|
|
|
|
|
|
|
|
zip = zipfile.ZipFile(tmp_file.name)
|
|
|
|
QtTest.QTest.qWait(2000)
|
|
|
|
self.assertEqual("onionshare", zip.read("test.txt").decode("utf-8"))
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def individual_file_is_viewable_or_not(self, tab):
|
|
|
|
"""Test whether an individual file is viewable (when in autostop_sharing is false) and that it isn't (when not in autostop_sharing is true)"""
|
|
|
|
url = f"http://127.0.0.1:{tab.app.port}"
|
|
|
|
download_file_url = f"http://127.0.0.1:{tab.app.port}/test.txt"
|
|
|
|
if tab.settings.get("general", "public"):
|
2019-11-08 03:20:38 -05:00
|
|
|
r = requests.get(url)
|
|
|
|
else:
|
|
|
|
r = requests.get(
|
|
|
|
url,
|
|
|
|
auth=requests.auth.HTTPBasicAuth(
|
2019-11-08 06:11:30 -05:00
|
|
|
"onionshare", tab.get_mode().server_status.web.password
|
2019-11-08 03:20:38 -05:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
if not tab.settings.get("share", "autostop_sharing"):
|
2019-11-08 03:20:38 -05:00
|
|
|
self.assertTrue('a href="test.txt"' in r.text)
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
if tab.settings.get("general", "public"):
|
2019-11-08 03:20:38 -05:00
|
|
|
r = requests.get(download_file_url)
|
|
|
|
else:
|
|
|
|
r = requests.get(
|
|
|
|
download_file_url,
|
|
|
|
auth=requests.auth.HTTPBasicAuth(
|
2019-11-08 06:11:30 -05:00
|
|
|
"onionshare", tab.get_mode().server_status.web.password
|
2019-11-08 03:20:38 -05:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
tmp_file = tempfile.NamedTemporaryFile()
|
|
|
|
with open(tmp_file.name, "wb") as f:
|
|
|
|
f.write(r.content)
|
|
|
|
|
|
|
|
with open(tmp_file.name, "r") as f:
|
|
|
|
self.assertEqual("onionshare", f.read())
|
|
|
|
else:
|
|
|
|
self.assertFalse('a href="/test.txt"' in r.text)
|
2019-11-08 06:11:30 -05:00
|
|
|
if tab.settings.get("general", "public"):
|
2019-11-08 03:20:38 -05:00
|
|
|
r = requests.get(download_file_url)
|
|
|
|
else:
|
|
|
|
r = requests.get(
|
|
|
|
download_file_url,
|
|
|
|
auth=requests.auth.HTTPBasicAuth(
|
2019-11-08 06:11:30 -05:00
|
|
|
"onionshare", tab.get_mode().server_status.web.password
|
2019-11-08 03:20:38 -05:00
|
|
|
),
|
|
|
|
)
|
|
|
|
self.assertEqual(r.status_code, 404)
|
2019-11-08 06:11:30 -05:00
|
|
|
self.download_share(tab)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
|
|
|
QtTest.QTest.qWait(2000)
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def hit_401(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test that the server stops after too many 401s, or doesn't when in public_mode"""
|
2019-11-08 06:11:30 -05:00
|
|
|
url = f"http://127.0.0.1:{tab.app.port}/"
|
2019-11-08 03:20:38 -05:00
|
|
|
|
|
|
|
for _ in range(20):
|
|
|
|
password_guess = self.gui.common.build_password()
|
2019-11-08 06:11:30 -05:00
|
|
|
requests.get(
|
2019-11-08 03:20:38 -05:00
|
|
|
url, auth=requests.auth.HTTPBasicAuth("onionshare", password_guess)
|
|
|
|
)
|
|
|
|
|
|
|
|
# A nasty hack to avoid the Alert dialog that blocks the rest of the test
|
2019-11-08 06:11:30 -05:00
|
|
|
if not tab.settings.get("general", "public"):
|
2019-11-08 03:20:38 -05:00
|
|
|
QtCore.QTimer.singleShot(1000, self.accept_dialog)
|
|
|
|
|
|
|
|
# In public mode, we should still be running (no rate-limiting)
|
2019-11-08 06:11:30 -05:00
|
|
|
if tab.settings.get("general", "public"):
|
|
|
|
self.web_server_is_running(tab)
|
2019-11-08 03:20:38 -05:00
|
|
|
# In non-public mode, we should be shut down (rate-limiting)
|
|
|
|
else:
|
2019-11-08 06:11:30 -05:00
|
|
|
self.web_server_is_stopped(tab)
|
|
|
|
|
|
|
|
# Auto-start timer tests
|
|
|
|
|
2019-11-08 06:59:20 -05:00
|
|
|
def set_autostart_timer(self, tab, timer):
|
2019-11-08 06:11:30 -05:00
|
|
|
"""Test that the timer can be set"""
|
|
|
|
schedule = QtCore.QDateTime.currentDateTime().addSecs(timer)
|
2019-11-08 06:59:20 -05:00
|
|
|
tab.get_mode().mode_settings_widget.autostart_timer_widget.setDateTime(schedule)
|
|
|
|
self.assertTrue(
|
|
|
|
tab.get_mode().mode_settings_widget.autostart_timer_widget.dateTime(),
|
|
|
|
schedule,
|
|
|
|
)
|
2019-11-08 06:11:30 -05:00
|
|
|
|
2019-11-08 07:06:24 -05:00
|
|
|
def autostart_timer_widget_hidden(self, tab):
|
2019-11-08 06:11:30 -05:00
|
|
|
"""Test that the auto-start timer widget is hidden when share has started"""
|
2019-11-08 06:59:20 -05:00
|
|
|
self.assertFalse(
|
|
|
|
tab.get_mode().mode_settings_widget.autostart_timer_widget.isVisible()
|
|
|
|
)
|
2019-11-08 06:11:30 -05:00
|
|
|
|
|
|
|
def scheduled_service_started(self, tab, mode, wait):
|
|
|
|
"""Test that the server has timed out after the timer ran out"""
|
|
|
|
QtTest.QTest.qWait(wait)
|
|
|
|
# We should have started now
|
2019-11-08 06:59:20 -05:00
|
|
|
self.assertEqual(tab.get_mode().server_status.status, 2)
|
2019-11-08 06:11:30 -05:00
|
|
|
|
|
|
|
def cancel_the_share(self, tab, mode):
|
|
|
|
"""Test that we can cancel a share before it's started up """
|
|
|
|
self.server_working_on_start_button_pressed(tab)
|
|
|
|
self.server_status_indicator_says_scheduled(tab)
|
|
|
|
self.add_delete_buttons_hidden(tab)
|
|
|
|
self.mode_settings_widget_is_hidden(tab)
|
|
|
|
self.set_autostart_timer(tab, 10)
|
2019-11-08 06:59:20 -05:00
|
|
|
QtTest.QTest.mousePress(
|
|
|
|
tab.get_mode().server_status.server_button, QtCore.Qt.LeftButton
|
|
|
|
)
|
2019-11-08 06:11:30 -05:00
|
|
|
QtTest.QTest.qWait(2000)
|
|
|
|
QtTest.QTest.mouseRelease(
|
2019-11-08 06:59:20 -05:00
|
|
|
tab.get_mode().server_status.server_button, QtCore.Qt.LeftButton
|
2019-11-08 06:11:30 -05:00
|
|
|
)
|
2019-11-08 06:59:20 -05:00
|
|
|
self.assertEqual(tab.get_mode().server_status.status, 0)
|
2019-11-08 06:11:30 -05:00
|
|
|
self.server_is_stopped(tab)
|
|
|
|
self.web_server_is_stopped(tab)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
|
|
|
# Grouped tests follow from here
|
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def run_all_share_mode_setup_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Tests in share mode prior to starting a share"""
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[0])
|
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(self.tmpfiles[1])
|
|
|
|
self.file_selection_widget_has_files(tab, 2)
|
|
|
|
self.history_is_not_visible(tab)
|
|
|
|
self.click_toggle_history(tab)
|
|
|
|
self.history_is_visible(tab)
|
|
|
|
self.deleting_all_files_hides_delete_button(tab)
|
|
|
|
self.add_a_file_and_delete_using_its_delete_widget(tab)
|
|
|
|
self.file_selection_widget_read_files(tab)
|
|
|
|
|
|
|
|
def run_all_share_mode_started_tests(self, tab, startup_time=2000):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Tests in share mode after starting a share"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.server_working_on_start_button_pressed(tab)
|
|
|
|
self.server_status_indicator_says_starting(tab)
|
|
|
|
self.add_delete_buttons_hidden(tab)
|
|
|
|
self.mode_settings_widget_is_hidden(tab)
|
|
|
|
self.server_is_started(tab, startup_time)
|
|
|
|
self.web_server_is_running(tab)
|
|
|
|
self.have_a_password(tab)
|
|
|
|
self.url_description_shown(tab)
|
|
|
|
self.have_copy_url_button(tab)
|
|
|
|
self.server_status_indicator_says_started(tab)
|
|
|
|
|
|
|
|
def run_all_share_mode_download_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Tests in share mode after downloading a share"""
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(
|
|
|
|
self.tmpfile_test
|
|
|
|
)
|
|
|
|
self.web_page(tab, "Total size")
|
|
|
|
self.download_share(tab)
|
|
|
|
self.history_widgets_present(tab)
|
|
|
|
self.server_is_stopped(tab)
|
|
|
|
self.web_server_is_stopped(tab)
|
|
|
|
self.server_status_indicator_says_closed(tab)
|
|
|
|
self.add_button_visible(tab)
|
|
|
|
self.server_working_on_start_button_pressed(tab)
|
|
|
|
self.toggle_indicator_is_reset(tab)
|
|
|
|
self.server_is_started(tab)
|
|
|
|
self.history_indicator(tab)
|
|
|
|
|
|
|
|
def run_all_share_mode_individual_file_download_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Tests in share mode after downloading a share"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.web_page(tab, "Total size")
|
|
|
|
self.individual_file_is_viewable_or_not(tab)
|
|
|
|
self.history_widgets_present(tab)
|
|
|
|
self.server_is_stopped(tab)
|
|
|
|
self.web_server_is_stopped(tab)
|
|
|
|
self.server_status_indicator_says_closed(tab)
|
|
|
|
self.add_button_visible(tab)
|
|
|
|
self.server_working_on_start_button_pressed(tab)
|
|
|
|
self.server_is_started(tab)
|
|
|
|
self.history_indicator(tab)
|
|
|
|
|
|
|
|
def run_all_share_mode_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""End-to-end share tests"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
|
|
|
self.run_all_share_mode_started_tests(tab)
|
|
|
|
self.run_all_share_mode_download_tests(tab)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def run_all_clear_all_button_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Test the Clear All history button"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
|
|
|
self.run_all_share_mode_started_tests(tab)
|
|
|
|
self.individual_file_is_viewable_or_not(tab)
|
|
|
|
self.history_widgets_present(tab)
|
|
|
|
self.clear_all_history_items(tab, 0)
|
|
|
|
self.individual_file_is_viewable_or_not(tab)
|
|
|
|
self.clear_all_history_items(tab, 2)
|
|
|
|
|
|
|
|
def run_all_share_mode_individual_file_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Tests in share mode when viewing an individual file"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
|
|
|
self.run_all_share_mode_started_tests(tab)
|
|
|
|
self.run_all_share_mode_individual_file_download_tests(tab)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def run_all_large_file_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Same as above but with a larger file"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
|
|
|
self.add_large_file(tab)
|
|
|
|
self.run_all_share_mode_started_tests(tab, startup_time=15000)
|
|
|
|
self.assertTrue(tab.filesize_warning.isVisible())
|
|
|
|
self.server_is_stopped(tab)
|
|
|
|
self.web_server_is_stopped(tab)
|
|
|
|
self.server_status_indicator_says_closed(tab)
|
|
|
|
|
|
|
|
def run_all_share_mode_persistent_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Same as end-to-end share tests but also test the password is the same on multiple shared"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
|
|
|
self.run_all_share_mode_started_tests(tab)
|
|
|
|
password = tab.get_mode().server_status.web.password
|
|
|
|
self.run_all_share_mode_download_tests(tab)
|
|
|
|
self.have_same_password(tab, password)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
2019-11-08 06:11:30 -05:00
|
|
|
def run_all_share_mode_timer_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Auto-stop timer tests in share mode"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
|
|
|
self.set_timeout(tab, 5)
|
|
|
|
self.run_all_share_mode_started_tests(tab)
|
|
|
|
self.autostop_timer_widget_hidden(tab)
|
|
|
|
self.server_timed_out(tab, 10000)
|
|
|
|
self.web_server_is_stopped(tab)
|
|
|
|
|
|
|
|
def run_all_share_mode_unreadable_file_tests(self, tab):
|
2019-11-08 03:20:38 -05:00
|
|
|
"""Attempt to share an unreadable file"""
|
2019-11-08 06:11:30 -05:00
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
2019-11-08 03:20:38 -05:00
|
|
|
QtCore.QTimer.singleShot(1000, self.accept_dialog)
|
2019-11-08 06:11:30 -05:00
|
|
|
tab.get_mode().server_status.file_selection.file_list.add_file(
|
2019-11-08 03:20:38 -05:00
|
|
|
"/tmp/nonexistent.txt"
|
|
|
|
)
|
2019-11-08 06:11:30 -05:00
|
|
|
self.file_selection_widget_has_files(tab, 2)
|
2019-11-08 03:20:38 -05:00
|
|
|
|
|
|
|
# Tests
|
|
|
|
|
|
|
|
@pytest.mark.gui
|
2019-11-08 06:59:20 -05:00
|
|
|
def test_autostart_and_autostop_timer_mismatch(self):
|
2019-11-08 07:06:24 -05:00
|
|
|
"""
|
|
|
|
If autostart timer is after autostop timer, a warning should be thrown
|
|
|
|
"""
|
2019-11-08 06:11:30 -05:00
|
|
|
tab = self.new_share_tab()
|
|
|
|
|
2019-11-08 06:59:20 -05:00
|
|
|
def accept_dialog():
|
|
|
|
window = tab.common.gui.qtapp.activeWindow()
|
|
|
|
if window:
|
|
|
|
window.close()
|
|
|
|
|
|
|
|
tab.get_mode().mode_settings_widget.toggle_advanced_button.click()
|
|
|
|
tab.get_mode().mode_settings_widget.autostart_timer_checkbox.click()
|
|
|
|
tab.get_mode().mode_settings_widget.autostop_timer_checkbox.click()
|
|
|
|
|
|
|
|
self.run_all_common_setup_tests()
|
|
|
|
|
|
|
|
self.run_all_share_mode_setup_tests(tab)
|
|
|
|
self.set_autostart_timer(tab, 15)
|
|
|
|
self.set_timeout(tab, 5)
|
|
|
|
QtCore.QTimer.singleShot(200, accept_dialog)
|
|
|
|
tab.get_mode().server_status.server_button.click()
|
|
|
|
self.server_is_stopped(tab)
|
2019-11-08 07:06:24 -05:00
|
|
|
|
|
|
|
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()
|