Qt test for UDP setting

This commit is contained in:
Dmitri Bogomolov 2021-02-28 18:35:30 +02:00
parent 79efacffb1
commit 6f9b66ddff
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 39 additions and 1 deletions

View File

@ -2,6 +2,10 @@
from addressbook import TestAddressbook from addressbook import TestAddressbook
from main import TestMain, TestUISignaler from main import TestMain, TestUISignaler
from settings import TestSettings
from support import TestSupport from support import TestSupport
__all__ = ["TestAddressbook", "TestMain", "TestSupport", "TestUISignaler"] __all__ = [
"TestAddressbook", "TestMain", "TestSettings", "TestSupport",
"TestUISignaler"
]

View File

@ -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')