From db285a01867cfcefdce70fcf7b1d88ff6b4fb69b Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 16 Jun 2020 22:37:11 +0300 Subject: [PATCH] Test case for Settings dialog --- src/bitmessageqt/tests/__init__.py | 3 +- src/bitmessageqt/tests/settings.py | 44 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/bitmessageqt/tests/settings.py diff --git a/src/bitmessageqt/tests/__init__.py b/src/bitmessageqt/tests/__init__.py index 199438f9..ef3fb3d9 100644 --- a/src/bitmessageqt/tests/__init__.py +++ b/src/bitmessageqt/tests/__init__.py @@ -1,6 +1,7 @@ """bitmessageqt tests""" from main import TestMain, TestUISignaler +from settings import TestSettings from support import TestSupport -__all__ = ["TestMain", "TestSupport", "TestUISignaler"] +__all__ = ["TestMain", "TestSettings", "TestSupport", "TestUISignaler"] diff --git a/src/bitmessageqt/tests/settings.py b/src/bitmessageqt/tests/settings.py new file mode 100644 index 00000000..619cbd61 --- /dev/null +++ b/src/bitmessageqt/tests/settings.py @@ -0,0 +1,44 @@ +from PyQt4 import QtCore, QtTest + +import state +from bmconfigparser import BMConfigParser +from bitmessageqt import settings + +from main import TestBase + + +class TestSettings(TestBase): + """A test case for the "Settings" dialog""" + + def test_dontconnect(self): + """Check that Settings dialog doesn't remove dontconnect""" + BMConfigParser().set('bitmessagesettings', 'dontconnect', 'true') + QtTest.QTest.qSleep(5005) + self.assertEqual(state.statusIconColor, 'red') + self.assertEqual( + BMConfigParser().safeGet( + 'bitmessagesettings', 'socksproxytype'), 'none') + # self.window.ui.actionSettings.trigger() + # dialog = self.app.activeWindow() + # self.assertIsInstance(dialog, settings.SettingsDialog) + dialog = settings.SettingsDialog(self.window) + dialog.comboBoxProxyType.setCurrentIndex(2) + # Accept later + QtCore.QTimer.singleShot( + 1, lambda: + QtTest.QTest.mouseClick( + dialog.buttonBox.button(dialog.buttonBox.Ok), + QtCore.Qt.LeftButton) + ) + dialog.exec_() + + self.assertFalse(dialog.net_restart_needed) + # QtTest.QTest.mouseClick(dialog.checkBoxUPnP, QtCore.Qt.LeftButton) + # QtTest.QTest.mouseClick(dialog.buttonBox.button(dialog.buttonBox.Ok), QtCore.Qt.LeftButton) + self.assertEqual( + BMConfigParser().safeGet( + 'bitmessagesettings', 'socksproxytype'), 'SOCKS5') + QtTest.QTest.qSleep(5050) + self.assertTrue( + BMConfigParser().safeGetBoolean( + 'bitmessagesettings', 'dontconnect'))