summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2019-03-25 13:43:08 +1100
committerMiguel Jacq <mig@mig5.net>2019-03-25 13:43:08 +1100
commit49285e047c43d97bf9c87a00859ecf74685f9228 (patch)
treef86e3e288bea43a80115f89c2b945e519787067b /tests
parentbd774ab448c37cad19f29f69eeb3ae30be1c3f73 (diff)
parentc1023647d1850c64a20514721d4397ff3c360671 (diff)
downloadonionshare-49285e047c43d97bf9c87a00859ecf74685f9228.tar.gz
onionshare-49285e047c43d97bf9c87a00859ecf74685f9228.zip
Fix conflicts
Diffstat (limited to 'tests')
-rw-r--r--tests/GuiReceiveTest.py25
-rw-r--r--tests/local_onionshare_receive_mode_sender_closed_test.py26
-rw-r--r--tests/test_onionshare_web.py2
3 files changed, 12 insertions, 41 deletions
diff --git a/tests/GuiReceiveTest.py b/tests/GuiReceiveTest.py
index 8a03283e..d1581c8e 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)
diff --git a/tests/local_onionshare_receive_mode_sender_closed_test.py b/tests/local_onionshare_receive_mode_sender_closed_test.py
deleted file mode 100644
index bfb9499a..00000000
--- a/tests/local_onionshare_receive_mode_sender_closed_test.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python3
-import pytest
-import unittest
-
-from .GuiReceiveTest import GuiReceiveTest
-
-class LocalReceiveModeSenderClosedTest(unittest.TestCase, GuiReceiveTest):
- @classmethod
- def setUpClass(cls):
- test_settings = {
- "receive_allow_receiver_shutdown": True
- }
- cls.gui = GuiReceiveTest.set_up(test_settings)
-
- @classmethod
- def tearDownClass(cls):
- GuiReceiveTest.tear_down()
-
- @pytest.mark.gui
- def test_gui(self):
- self.run_all_common_setup_tests()
- self.run_all_receive_mode_tests(False, True)
- self.run_receive_mode_sender_closed_tests(False)
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/test_onionshare_web.py b/tests/test_onionshare_web.py
index 3f9540ae..0c29859b 100644
--- a/tests/test_onionshare_web.py
+++ b/tests/test_onionshare_web.py
@@ -41,7 +41,7 @@ RANDOM_STR_REGEX = re.compile(r'^[a-z2-7]+$')
def web_obj(common_obj, mode, num_files=0):
""" Creates a Web object, in either share mode or receive mode, ready for testing """
- common_obj.load_settings()
+ common_obj.settings = Settings(common_obj)
strings.load_strings(common_obj)
web = Web(common_obj, False, mode)
web.generate_slug()