From 6f9b66ddffa27673b9c9effe299fed6fddd7bb2c Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Sun, 28 Feb 2021 18:35:30 +0200 Subject: [PATCH] Qt test for UDP setting --- src/bitmessageqt/tests/__init__.py | 6 +++++- src/bitmessageqt/tests/settings.py | 34 ++++++++++++++++++++++++++++++ 2 files changed, 39 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 69766014..a542abdc 100644 --- a/src/bitmessageqt/tests/__init__.py +++ b/src/bitmessageqt/tests/__init__.py @@ -2,6 +2,10 @@ from addressbook import TestAddressbook from main import TestMain, TestUISignaler +from settings import TestSettings from support import TestSupport -__all__ = ["TestAddressbook", "TestMain", "TestSupport", "TestUISignaler"] +__all__ = [ + "TestAddressbook", "TestMain", "TestSettings", "TestSupport", + "TestUISignaler" +] diff --git a/src/bitmessageqt/tests/settings.py b/src/bitmessageqt/tests/settings.py new file mode 100644 index 00000000..c0708b5c --- /dev/null +++ b/src/bitmessageqt/tests/settings.py @@ -0,0 +1,34 @@ +import threading +import time + +from main import TestBase +from bmconfigparser import BMConfigParser +from bitmessageqt import settings + + +class TestSettings(TestBase): + """A test case for the "Settings" dialog""" + def setUp(self): + super(TestSettings, self).setUp() + self.dialog = settings.SettingsDialog(self.window) + + def test_udp(self): + """Test the effect of checkBoxUDP""" + udp_setting = BMConfigParser().safeGetBoolean( + 'bitmessagesettings', 'udp') + self.assertEqual(udp_setting, self.dialog.checkBoxUDP.isChecked()) + self.dialog.checkBoxUDP.setChecked(not udp_setting) + self.dialog.accept() + self.assertEqual( + not udp_setting, + BMConfigParser().safeGetBoolean('bitmessagesettings', 'udp')) + time.sleep(5) + for thread in threading.enumerate(): + if thread.name == 'Announcer': # find Announcer thread + if udp_setting: + self.fail( + 'Announcer thread is running while udp set to False') + break + else: + if not udp_setting: + self.fail('No Announcer thread found while udp set to True')