aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-01-21 17:11:58 -0800
committerMicah Lee <micah@micahflee.com>2019-01-21 17:11:58 -0800
commit6822c7435fe3687633c630195a7b1cee51c03b73 (patch)
treef2179129b0e10008ae948e4b42b6418d72577771
parent87d94f68e89d4fd42e68183a2aee8a2fffef07b7 (diff)
downloadonionshare-6822c7435fe3687633c630195a7b1cee51c03b73.tar.gz
onionshare-6822c7435fe3687633c630195a7b1cee51c03b73.zip
Write test to confirm that submitting the receive mode form without selecting files doesn't change in_progress_count or completed_count
-rw-r--r--onionshare/web/receive_mode.py2
-rw-r--r--tests/GuiReceiveTest.py23
2 files changed, 24 insertions, 1 deletions
diff --git a/onionshare/web/receive_mode.py b/onionshare/web/receive_mode.py
index 5e332a39..30414b77 100644
--- a/onionshare/web/receive_mode.py
+++ b/onionshare/web/receive_mode.py
@@ -67,7 +67,7 @@ class ReceiveModeWeb(object):
receive_mode_dir = os.path.join(self.common.settings.get('data_dir'), date_dir, time_dir)
valid = True
try:
- os.makedirs(receive_mode_dir, 0o700)
+ os.makedirs(receive_mode_dir, 0o700, exist_ok=True)
except PermissionError:
self.web.add_request(self.web.REQUEST_ERROR_DATA_DIR_CANNOT_CREATE, request.path, {
"receive_mode_dir": receive_mode_dir
diff --git a/tests/GuiReceiveTest.py b/tests/GuiReceiveTest.py
index a23a4bc6..8a03283e 100644
--- a/tests/GuiReceiveTest.py
+++ b/tests/GuiReceiveTest.py
@@ -52,6 +52,28 @@ class GuiReceiveTest(GuiBaseTest):
response = requests.get('http://127.0.0.1:{}/close'.format(self.gui.app.port))
self.assertEqual(response.status_code, 404)
+ def uploading_zero_files_shouldnt_change_ui(self, mode, public_mode):
+ '''If you submit the receive mode form without selecting any files, the UI shouldn't get updated'''
+ if not public_mode:
+ path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.slug)
+ else:
+ path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
+
+ # What were the counts before submitting the form?
+ before_in_progress_count = mode.history.in_progress_count
+ before_completed_count = mode.history.completed_count
+ before_number_of_history_items = len(mode.history.item_list.items)
+
+ # Click submit without including any files a few times
+ response = requests.post(path, files={})
+ response = requests.post(path, files={})
+ response = requests.post(path, files={})
+
+ # The counts shouldn't change
+ self.assertEqual(mode.history.in_progress_count, before_in_progress_count)
+ 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:
@@ -97,6 +119,7 @@ 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)
+ 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)
self.web_server_is_stopped()