From d18b77e85453ae269f2c634e549a2e46ffc2472d Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 30 Sep 2018 18:32:18 -0700 Subject: [PATCH] Fix the rest of the local GUI tests --- .../onionshare_receive_mode_upload_test.py | 57 +------------------ ...re_receive_mode_upload_test_public_mode.py | 1 - .../onionshare_share_mode_download_test.py | 55 +----------------- ...re_share_mode_download_test_public_mode.py | 56 +----------------- ...hare_share_mode_download_test_stay_open.py | 55 +----------------- .../onionshare_slug_persistent_test.py | 56 +----------------- tests_gui_local/onionshare_timer_test.py | 55 +----------------- 7 files changed, 18 insertions(+), 317 deletions(-) diff --git a/tests_gui_local/onionshare_receive_mode_upload_test.py b/tests_gui_local/onionshare_receive_mode_upload_test.py index 2aa2ed94..cf439950 100644 --- a/tests_gui_local/onionshare_receive_mode_upload_test.py +++ b/tests_gui_local/onionshare_receive_mode_upload_test.py @@ -15,68 +15,17 @@ from onionshare_gui import * from .commontests import CommonTests class OnionShareGuiTest(unittest.TestCase): - '''Test the OnionShare GUI''' @classmethod def setUpClass(cls): - '''Create the GUI''' - # Create our test file - testfile = open('/tmp/test.txt', 'w') - testfile.write('onionshare') - testfile.close() - common = Common() - common.define_css() - - # Start the Onion - strings.load_strings(common) - - testonion = onion.Onion(common) - global qtapp - qtapp = Application(common) - app = OnionShare(common, testonion, True, 0) - - web = Web(common, False, True) - test_settings = { - "auth_password": "", - "auth_type": "no_auth", - "autoupdate_timestamp": "", - "close_after_first_download": True, - "connection_type": "bundled", - "control_port_address": "127.0.0.1", - "control_port_port": 9051, - "downloads_dir": "/tmp/OnionShare", - "hidservauth_string": "", - "no_bridges": True, - "private_key": "", "public_mode": False, - "receive_allow_receiver_shutdown": True, - "save_private_key": False, - "shutdown_timeout": False, - "slug": "", - "socks_address": "127.0.0.1", - "socks_port": 9050, - "socket_file_path": "/var/run/tor/control", - "systray_notifications": True, - "tor_bridges_use_meek_lite_azure": False, - "tor_bridges_use_meek_lite_amazon": False, - "tor_bridges_use_custom_bridges": "", - "tor_bridges_use_obfs4": False, - "use_stealth": False, - "use_legacy_v2_onions": False, - "use_autoupdate": True, - "version": "1.3.1" + "receive_allow_receiver_shutdown": True } - testsettings = '/tmp/testsettings.json' - open(testsettings, 'w').write(json.dumps(test_settings)) - - cls.gui = OnionShareGui(common, testonion, qtapp, app, ['/tmp/test.txt'], testsettings, True) + cls.gui = CommonTests.set_up(test_settings) @classmethod def tearDownClass(cls): - '''Clean up after tests''' - os.remove('/tmp/test.txt') - os.remove('/tmp/OnionShare/test.txt') - os.remove('/tmp/OnionShare/test-2.txt') + CommonTests.tear_down() @pytest.mark.run(order=1) def test_gui_loaded(self): diff --git a/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py b/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py index 7b1cfe79..f89da51a 100644 --- a/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py +++ b/tests_gui_local/onionshare_receive_mode_upload_test_public_mode.py @@ -16,7 +16,6 @@ from onionshare_gui import * from .commontests import CommonTests class OnionShareGuiTest(unittest.TestCase): - '''Test the OnionShare GUI''' @classmethod def setUpClass(cls): test_settings = { diff --git a/tests_gui_local/onionshare_share_mode_download_test.py b/tests_gui_local/onionshare_share_mode_download_test.py index c546fb61..1800150f 100644 --- a/tests_gui_local/onionshare_share_mode_download_test.py +++ b/tests_gui_local/onionshare_share_mode_download_test.py @@ -15,66 +15,17 @@ from onionshare_gui import * from .commontests import CommonTests class OnionShareGuiTest(unittest.TestCase): - '''Test the OnionShare GUI''' @classmethod def setUpClass(cls): - '''Create the GUI''' - # Create our test file - testfile = open('/tmp/test.txt', 'w') - testfile.write('onionshare') - testfile.close() - common = Common() - common.define_css() - - # Start the Onion - strings.load_strings(common) - - testonion = onion.Onion(common) - global qtapp - qtapp = Application(common) - app = OnionShare(common, testonion, True, 0) - - web = Web(common, False, True) - test_settings = { - "auth_password": "", - "auth_type": "no_auth", - "autoupdate_timestamp": "", - "close_after_first_download": True, - "connection_type": "bundled", - "control_port_address": "127.0.0.1", - "control_port_port": 9051, - "downloads_dir": "/tmp/OnionShare", - "hidservauth_string": "", - "no_bridges": True, - "private_key": "", "public_mode": False, - "receive_allow_receiver_shutdown": True, - "save_private_key": False, - "shutdown_timeout": False, - "slug": "", - "socks_address": "127.0.0.1", - "socks_port": 9050, - "socket_file_path": "/var/run/tor/control", - "systray_notifications": True, - "tor_bridges_use_meek_lite_azure": False, - "tor_bridges_use_meek_lite_amazon": False, - "tor_bridges_use_custom_bridges": "", - "tor_bridges_use_obfs4": False, - "use_stealth": False, - "use_legacy_v2_onions": False, - "use_autoupdate": True, - "version": "1.3.1" + "close_after_first_download": True } - testsettings = '/tmp/testsettings.json' - open(testsettings, 'w').write(json.dumps(test_settings)) - - cls.gui = OnionShareGui(common, testonion, qtapp, app, ['/tmp/test.txt'], testsettings, True) + cls.gui = CommonTests.set_up(test_settings) @classmethod def tearDownClass(cls): - '''Clean up after tests''' - os.remove('/tmp/test.txt') + CommonTests.tear_down() @pytest.mark.run(order=1) def test_gui_loaded(self): diff --git a/tests_gui_local/onionshare_share_mode_download_test_public_mode.py b/tests_gui_local/onionshare_share_mode_download_test_public_mode.py index 764b5885..37c593f9 100644 --- a/tests_gui_local/onionshare_share_mode_download_test_public_mode.py +++ b/tests_gui_local/onionshare_share_mode_download_test_public_mode.py @@ -15,66 +15,16 @@ from onionshare_gui import * from .commontests import CommonTests class OnionShareGuiTest(unittest.TestCase): - '''Test the OnionShare GUI''' @classmethod def setUpClass(cls): - '''Create the GUI''' - # Create our test file - testfile = open('/tmp/test.txt', 'w') - testfile.write('onionshare') - testfile.close() - common = Common() - common.define_css() - - # Start the Onion - strings.load_strings(common) - - testonion = onion.Onion(common) - global qtapp - qtapp = Application(common) - app = OnionShare(common, testonion, True, 0) - - web = Web(common, False, True) - test_settings = { - "auth_password": "", - "auth_type": "no_auth", - "autoupdate_timestamp": "", - "close_after_first_download": True, - "connection_type": "bundled", - "control_port_address": "127.0.0.1", - "control_port_port": 9051, - "downloads_dir": "/tmp/OnionShare", - "hidservauth_string": "", - "no_bridges": True, - "private_key": "", - "public_mode": True, - "receive_allow_receiver_shutdown": True, - "save_private_key": False, - "shutdown_timeout": False, - "slug": "", - "socks_address": "127.0.0.1", - "socks_port": 9050, - "socket_file_path": "/var/run/tor/control", - "systray_notifications": True, - "tor_bridges_use_meek_lite_azure": False, - "tor_bridges_use_meek_lite_amazon": False, - "tor_bridges_use_custom_bridges": "", - "tor_bridges_use_obfs4": False, - "use_stealth": False, - "use_legacy_v2_onions": False, - "use_autoupdate": True, - "version": "1.3.1" + "public_mode": True } - testsettings = '/tmp/testsettings.json' - open(testsettings, 'w').write(json.dumps(test_settings)) - - cls.gui = OnionShareGui(common, testonion, qtapp, app, ['/tmp/test.txt'], testsettings, True) + cls.gui = CommonTests.set_up(test_settings) @classmethod def tearDownClass(cls): - '''Clean up after tests''' - os.remove('/tmp/test.txt') + CommonTests.tear_down() @pytest.mark.run(order=1) def test_gui_loaded(self): diff --git a/tests_gui_local/onionshare_share_mode_download_test_stay_open.py b/tests_gui_local/onionshare_share_mode_download_test_stay_open.py index b92ff097..57ea8424 100644 --- a/tests_gui_local/onionshare_share_mode_download_test_stay_open.py +++ b/tests_gui_local/onionshare_share_mode_download_test_stay_open.py @@ -15,66 +15,17 @@ from onionshare_gui import * from .commontests import CommonTests class OnionShareGuiTest(unittest.TestCase): - '''Test the OnionShare GUI''' @classmethod def setUpClass(cls): - '''Create the GUI''' - # Create our test file - testfile = open('/tmp/test.txt', 'w') - testfile.write('onionshare') - testfile.close() - common = Common() - common.define_css() - - # Start the Onion - strings.load_strings(common) - - testonion = onion.Onion(common) - global qtapp - qtapp = Application(common) - app = OnionShare(common, testonion, True, 0) - - web = Web(common, False, True) - test_settings = { - "auth_password": "", - "auth_type": "no_auth", - "autoupdate_timestamp": "", - "close_after_first_download": False, - "connection_type": "bundled", - "control_port_address": "127.0.0.1", - "control_port_port": 9051, - "downloads_dir": "/tmp/OnionShare", - "hidservauth_string": "", - "no_bridges": True, - "private_key": "", "public_mode": True, - "receive_allow_receiver_shutdown": True, - "save_private_key": False, - "shutdown_timeout": False, - "slug": "", - "socks_address": "127.0.0.1", - "socks_port": 9050, - "socket_file_path": "/var/run/tor/control", - "systray_notifications": True, - "tor_bridges_use_meek_lite_azure": False, - "tor_bridges_use_meek_lite_amazon": False, - "tor_bridges_use_custom_bridges": "", - "tor_bridges_use_obfs4": False, - "use_stealth": False, - "use_legacy_v2_onions": False, - "use_autoupdate": True, - "version": "1.3.1" + "close_after_first_download": False } - testsettings = '/tmp/testsettings.json' - open(testsettings, 'w').write(json.dumps(test_settings)) - - cls.gui = OnionShareGui(common, testonion, qtapp, app, ['/tmp/test.txt'], testsettings, True) + cls.gui = CommonTests.set_up(test_settings) @classmethod def tearDownClass(cls): - '''Clean up after tests''' - os.remove('/tmp/test.txt') + CommonTests.tear_down() @pytest.mark.run(order=1) def test_gui_loaded(self): diff --git a/tests_gui_local/onionshare_slug_persistent_test.py b/tests_gui_local/onionshare_slug_persistent_test.py index 1e5614dc..54652eeb 100644 --- a/tests_gui_local/onionshare_slug_persistent_test.py +++ b/tests_gui_local/onionshare_slug_persistent_test.py @@ -15,68 +15,18 @@ from onionshare_gui import * from .commontests import CommonTests class OnionShareGuiTest(unittest.TestCase): - '''Test the OnionShare GUI''' - slug = '' - @classmethod def setUpClass(cls): - '''Create the GUI''' - # Create our test file - testfile = open('/tmp/test.txt', 'w') - testfile.write('onionshare') - testfile.close() - common = Common() - common.define_css() - - # Start the Onion - strings.load_strings(common) - - testonion = onion.Onion(common) - global qtapp - qtapp = Application(common) - app = OnionShare(common, testonion, True, 0) - - web = Web(common, False, True) - test_settings = { - "auth_password": "", - "auth_type": "no_auth", - "autoupdate_timestamp": "", - "close_after_first_download": True, - "connection_type": "bundled", - "control_port_address": "127.0.0.1", - "control_port_port": 9051, - "downloads_dir": "/tmp/OnionShare", - "hidservauth_string": "", - "no_bridges": True, - "private_key": "", "public_mode": False, - "receive_allow_receiver_shutdown": True, - "save_private_key": True, - "shutdown_timeout": False, "slug": "", - "socks_address": "127.0.0.1", - "socks_port": 9050, - "socket_file_path": "/var/run/tor/control", - "systray_notifications": True, - "tor_bridges_use_meek_lite_azure": False, - "tor_bridges_use_meek_lite_amazon": False, - "tor_bridges_use_custom_bridges": "", - "tor_bridges_use_obfs4": False, - "use_stealth": False, - "use_legacy_v2_onions": False, - "use_autoupdate": True, - "version": "1.3.1" + "save_private_key": True } - testsettings = '/tmp/testsettings.json' - open(testsettings, 'w').write(json.dumps(test_settings)) - - cls.gui = OnionShareGui(common, testonion, qtapp, app, ['/tmp/test.txt'], testsettings, True) + cls.gui = CommonTests.set_up(test_settings) @classmethod def tearDownClass(cls): - '''Clean up after tests''' - os.remove('/tmp/test.txt') + CommonTests.tear_down() @pytest.mark.run(order=1) def test_gui_loaded(self): diff --git a/tests_gui_local/onionshare_timer_test.py b/tests_gui_local/onionshare_timer_test.py index 1a5134e2..26eb4560 100644 --- a/tests_gui_local/onionshare_timer_test.py +++ b/tests_gui_local/onionshare_timer_test.py @@ -15,66 +15,17 @@ from onionshare_gui import * from .commontests import CommonTests class OnionShareGuiTest(unittest.TestCase): - '''Test the OnionShare GUI''' @classmethod def setUpClass(cls): - '''Create the GUI''' - # Create our test file - testfile = open('/tmp/test.txt', 'w') - testfile.write('onionshare') - testfile.close() - common = Common() - common.define_css() - - # Start the Onion - strings.load_strings(common) - - testonion = onion.Onion(common) - global qtapp - qtapp = Application(common) - app = OnionShare(common, testonion, True, 0) - - web = Web(common, False, True) - test_settings = { - "auth_password": "", - "auth_type": "no_auth", - "autoupdate_timestamp": "", - "close_after_first_download": True, - "connection_type": "bundled", - "control_port_address": "127.0.0.1", - "control_port_port": 9051, - "downloads_dir": "/tmp/OnionShare", - "hidservauth_string": "", - "no_bridges": True, - "private_key": "", "public_mode": False, - "receive_allow_receiver_shutdown": True, - "save_private_key": False, - "shutdown_timeout": True, - "slug": "", - "socks_address": "127.0.0.1", - "socks_port": 9050, - "socket_file_path": "/var/run/tor/control", - "systray_notifications": True, - "tor_bridges_use_meek_lite_azure": False, - "tor_bridges_use_meek_lite_amazon": False, - "tor_bridges_use_custom_bridges": "", - "tor_bridges_use_obfs4": False, - "use_stealth": False, - "use_legacy_v2_onions": False, - "use_autoupdate": True, - "version": "1.3.1" + "shutdown_timeout": True } - testsettings = '/tmp/testsettings.json' - open(testsettings, 'w').write(json.dumps(test_settings)) - - cls.gui = OnionShareGui(common, testonion, qtapp, app, ['/tmp/test.txt'], testsettings, True) + cls.gui = CommonTests.set_up(test_settings) @classmethod def tearDownClass(cls): - '''Clean up after tests''' - os.remove('/tmp/test.txt') + CommonTests.tear_down() @pytest.mark.run(order=1) def test_gui_loaded(self):