Fix tests in Receive Mode that actually do increment the history item widget count where they didn't previously (due to an additional GET that follows the 302 redirect of a POST request on upload)

This commit is contained in:
Miguel Jacq 2019-09-09 12:19:39 +10:00
parent 26c9256679
commit 8e238ab2d6
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
2 changed files with 4 additions and 30 deletions

View File

@ -116,7 +116,7 @@ class GuiBaseTest(object):
self.assertEqual(mode.history.isVisible(), not currently_visible)
def history_indicator(self, mode, public_mode):
def history_indicator(self, mode, public_mode, indicator_count="1"):
'''Test that we can make sure the history is toggled off, do an action, and the indiciator works'''
# Make sure history is toggled off
if mode.history.isVisible():
@ -147,7 +147,7 @@ class GuiBaseTest(object):
# Indicator should be visible, have a value of "1"
self.assertTrue(mode.toggle_history.indicator_label.isVisible())
self.assertEqual(mode.toggle_history.indicator_label.text(), "1")
self.assertEqual(mode.toggle_history.indicator_label.text(), indicator_count)
# Toggle history back on, indicator should be hidden again
QtTest.QTest.mouseClick(mode.toggle_history, QtCore.Qt.LeftButton)

View File

@ -66,31 +66,6 @@ class GuiReceiveTest(GuiBaseTest):
r = requests.get('http://127.0.0.1:{}/close'.format(self.gui.app.port))
self.assertEqual(r.status_code, 401)
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'''
url = '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
if public_mode:
r = requests.post(url, files={})
r = requests.post(url, files={})
r = requests.post(url, files={})
else:
auth = requests.auth.HTTPBasicAuth('onionshare', mode.web.password)
r = requests.post(url, files={}, auth=auth)
r = requests.post(url, files={}, auth=auth)
r = requests.post(url, files={}, auth=auth)
# 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)
# 'Grouped' tests follow from here
def run_all_receive_mode_setup_tests(self, public_mode):
@ -127,14 +102,13 @@ class GuiReceiveTest(GuiBaseTest):
# 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.history_indicator(self.gui.receive_mode, public_mode, "2")
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)
self.server_working_on_start_button_pressed(self.gui.receive_mode)
self.server_is_started(self.gui.receive_mode)
self.history_indicator(self.gui.receive_mode, public_mode)
self.history_indicator(self.gui.receive_mode, public_mode, "2")
def run_all_receive_mode_unwritable_dir_tests(self, public_mode):
'''Attempt to upload (unwritable) files in receive mode and stop the share'''