mirror of
https://github.com/kk7ds/chirp.git
synced 2024-09-21 18:47:18 +00:00
06176e6202
This has been a long time coming. Our tests have always been a bit weird because when we added them, there weren't great ways of loading dynamic test classes with the runners at the time. That is now much better. With everyone running tests via tox and the unittest framework, we can move our tests out of the adapter and into proper test cases. We still need the custom loader to generate classes based on test images, but it's majorly simpler and uses the hooks available. With this, each test case is broken into proper scenarios so that each can be run (and fail) independently. We also don't need all the wrapper and logging stuff, which means exceptions are reported where they actually happen, and as such, debugging what is failing should be much easier. The content is mostly the same, although the detect test is tightend a bit, just because it needed rewriting anyway. That uncovered the bug in the test images fixed a few patches ago.
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
from chirp import settings
|
|
from tests import base
|
|
|
|
|
|
class TestCaseSettings(base.DriverTest):
|
|
def test_has_settings(self):
|
|
return
|
|
settings = self.radio.get_settings()
|
|
if settings:
|
|
self.assertFalse(self.rf.has_settings,
|
|
'Radio returned settings but has_settings=False')
|
|
else:
|
|
self.assertTrue(self.rf.has_settings,
|
|
'Radio returned no settings but has_settings=True')
|
|
|
|
@base.requires_feature('has_settings')
|
|
def test_get_settings(self):
|
|
lst = self.radio.get_settings()
|
|
self.assertIsInstance(lst, list)
|
|
|
|
@base.requires_feature('has_settings')
|
|
def test_same_settings(self):
|
|
o = self.radio.get_settings()
|
|
self.radio.set_settings(o)
|
|
n = self.radio.get_settings()
|
|
list(map(self.compare_settings, o, n))
|
|
|
|
def compare_settings(self, a, b):
|
|
try:
|
|
if isinstance(a, settings.RadioSettingValue):
|
|
raise StopIteration
|
|
list(map(self.compare_settings, a, b))
|
|
except StopIteration:
|
|
self.assertEqual(a.get_value(), b.get_value(),
|
|
'Setting value changed from %r to %r' % (
|
|
a.get_value(), b.get_value()))
|