mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-24 06:24:19 -04:00
Fix the discrepancy between SendBaseModeWeb and Web objects' separate cur_history_id attibutes, ensuring that when we call web.error404() we send a new history_id integer for communicating back to the frontend. Add tests for this
This commit is contained in:
parent
4a4437394d
commit
2c87ea55ff
9 changed files with 92 additions and 15 deletions
|
@ -285,6 +285,10 @@ class GuiBaseTest(object):
|
|||
else:
|
||||
self.assertEqual(self.gui.share_mode.server_status_label.text(), strings._('closing_automatically'))
|
||||
|
||||
def clear_all_history_items(self, mode, count):
|
||||
if count == 0:
|
||||
QtTest.QTest.mouseClick(mode.history.clear_button, QtCore.Qt.LeftButton)
|
||||
self.assertEquals(len(mode.history.item_list.items.keys()), count)
|
||||
|
||||
# Auto-stop timer tests
|
||||
def set_timeout(self, mode, timeout):
|
||||
|
|
|
@ -127,3 +127,12 @@ class GuiReceiveTest(GuiBaseTest):
|
|||
self.autostop_timer_widget_hidden(self.gui.receive_mode)
|
||||
self.server_timed_out(self.gui.receive_mode, 15000)
|
||||
self.web_server_is_stopped()
|
||||
|
||||
def run_all_clear_all_button_tests(self, public_mode):
|
||||
"""Test the Clear All history button"""
|
||||
self.run_all_receive_mode_setup_tests(public_mode)
|
||||
self.upload_file(public_mode, '/tmp/test.txt', 'test.txt')
|
||||
self.history_widgets_present(self.gui.receive_mode)
|
||||
self.clear_all_history_items(self.gui.receive_mode, 0)
|
||||
self.upload_file(public_mode, '/tmp/test.txt', 'test.txt')
|
||||
self.clear_all_history_items(self.gui.receive_mode, 2)
|
||||
|
|
|
@ -196,6 +196,15 @@ class GuiShareTest(GuiBaseTest):
|
|||
self.run_all_share_mode_started_tests(public_mode)
|
||||
self.run_all_share_mode_download_tests(public_mode, stay_open)
|
||||
|
||||
def run_all_clear_all_button_tests(self, public_mode, stay_open):
|
||||
"""Test the Clear All history button"""
|
||||
self.run_all_share_mode_setup_tests()
|
||||
self.run_all_share_mode_started_tests(public_mode)
|
||||
self.individual_file_is_viewable_or_not(public_mode, stay_open)
|
||||
self.history_widgets_present(self.gui.share_mode)
|
||||
self.clear_all_history_items(self.gui.share_mode, 0)
|
||||
self.individual_file_is_viewable_or_not(public_mode, stay_open)
|
||||
self.clear_all_history_items(self.gui.share_mode, 2)
|
||||
|
||||
def run_all_share_mode_individual_file_tests(self, public_mode, stay_open):
|
||||
"""Tests in share mode when viewing an individual file"""
|
||||
|
|
25
tests/local_onionshare_receive_mode_clear_all_button_test.py
Normal file
25
tests/local_onionshare_receive_mode_clear_all_button_test.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python3
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from .GuiReceiveTest import GuiReceiveTest
|
||||
|
||||
class LocalReceiveModeClearAllButtonTest(unittest.TestCase, GuiReceiveTest):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
test_settings = {
|
||||
}
|
||||
cls.gui = GuiReceiveTest.set_up(test_settings)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
GuiReceiveTest.tear_down()
|
||||
|
||||
@pytest.mark.gui
|
||||
@pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
|
||||
def test_gui(self):
|
||||
self.run_all_common_setup_tests()
|
||||
self.run_all_clear_all_button_tests(False)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
26
tests/local_onionshare_share_mode_clear_all_button_test.py
Normal file
26
tests/local_onionshare_share_mode_clear_all_button_test.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from .GuiShareTest import GuiShareTest
|
||||
|
||||
class LocalShareModeClearAllButtonTest(unittest.TestCase, GuiShareTest):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
test_settings = {
|
||||
"close_after_first_download": False,
|
||||
}
|
||||
cls.gui = GuiShareTest.set_up(test_settings)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
GuiShareTest.tear_down()
|
||||
|
||||
@pytest.mark.gui
|
||||
@pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
|
||||
def test_gui(self):
|
||||
self.run_all_common_setup_tests()
|
||||
self.run_all_clear_all_button_tests(False, True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
Add table
Add a link
Reference in a new issue