summaryrefslogtreecommitdiff
path: root/tests/GuiReceiveTest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/GuiReceiveTest.py')
-rw-r--r--tests/GuiReceiveTest.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/tests/GuiReceiveTest.py b/tests/GuiReceiveTest.py
index 8a03283e..40c3de95 100644
--- a/tests/GuiReceiveTest.py
+++ b/tests/GuiReceiveTest.py
@@ -5,7 +5,7 @@ from PyQt5 import QtCore, QtTest
from .GuiBaseTest import GuiBaseTest
class GuiReceiveTest(GuiBaseTest):
- def upload_file(self, public_mode, file_to_upload, expected_basename):
+ def upload_file(self, public_mode, file_to_upload, expected_basename, identical_files_at_once=False):
'''Test that we can upload the file'''
files = {'file[]': open(file_to_upload, 'rb')}
if not public_mode:
@@ -13,6 +13,9 @@ class GuiReceiveTest(GuiBaseTest):
else:
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
response = requests.post(path, files=files)
+ if identical_files_at_once:
+ # Send a duplicate upload to test for collisions
+ response = requests.post(path, files=files)
QtTest.QTest.qWait(2000)
# Make sure the file is within the last 10 seconds worth of filenames
@@ -20,7 +23,10 @@ class GuiReceiveTest(GuiBaseTest):
now = datetime.now()
for i in range(10):
date_dir = now.strftime("%Y-%m-%d")
- time_dir = now.strftime("%H.%M.%S")
+ if identical_files_at_once:
+ time_dir = now.strftime("%H.%M.%S-1")
+ else:
+ time_dir = now.strftime("%H.%M.%S")
receive_mode_dir = os.path.join(self.gui.common.settings.get('data_dir'), date_dir, time_dir)
expected_filename = os.path.join(receive_mode_dir, expected_basename)
if os.path.exists(expected_filename):
@@ -74,18 +80,6 @@ class GuiReceiveTest(GuiBaseTest):
self.assertEqual(mode.history.completed_count, before_completed_count)
self.assertEqual(len(mode.history.item_list.items), before_number_of_history_items)
- def run_receive_mode_sender_closed_tests(self, public_mode):
- '''Test that the share can be stopped by the sender in receive mode'''
- if not public_mode:
- path = 'http://127.0.0.1:{}/{}/close'.format(self.gui.app.port, self.gui.receive_mode.web.slug)
- else:
- path = 'http://127.0.0.1:{}/close'.format(self.gui.app.port)
- response = requests.post(path)
- self.server_is_stopped(self.gui.receive_mode, False)
- self.web_server_is_stopped()
- self.server_status_indicator_says_closed(self.gui.receive_mode, False)
-
-
# 'Grouped' tests follow from here
def run_all_receive_mode_setup_tests(self, public_mode):
@@ -119,6 +113,9 @@ class GuiReceiveTest(GuiBaseTest):
self.counter_incremented(self.gui.receive_mode, 3)
self.upload_file(public_mode, '/tmp/testdir/test', 'test')
self.counter_incremented(self.gui.receive_mode, 4)
+ # Test uploading the same file twice at the same time, and make sure no collisions
+ self.upload_file(public_mode, '/tmp/test.txt', 'test.txt', True)
+ self.counter_incremented(self.gui.receive_mode, 6)
self.uploading_zero_files_shouldnt_change_ui(self.gui.receive_mode, public_mode)
self.history_indicator(self.gui.receive_mode, public_mode)
self.server_is_stopped(self.gui.receive_mode, False)
@@ -142,6 +139,6 @@ class GuiReceiveTest(GuiBaseTest):
"""Auto-stop timer tests in receive mode"""
self.run_all_receive_mode_setup_tests(public_mode)
self.set_timeout(self.gui.receive_mode, 5)
- self.timeout_widget_hidden(self.gui.receive_mode)
+ self.autostop_timer_widget_hidden(self.gui.receive_mode)
self.server_timed_out(self.gui.receive_mode, 15000)
self.web_server_is_stopped()