# HG changeset patch
# User K. Arvanitis <kosta@alumni.uvic.ca>
# Date 1421988817 28800
#      Thu Jan 22 20:53:37 2015 -0800
# Node ID e347fdbfc9c2ce3a80bf037c2a7667afda8eed13
# Parent  b25606106a9c0cd78f3cc5f602475da64cde081d
[PATCH] Add Support for Settings UnitTest
Add a basic unit test  coverage of the radio Settings API.
Currently, all but one image passes the test (UV3R).
Commented out offending code in uv3r module.
Feature #2235
diff -r b25606106a9c -r e347fdbfc9c2 chirp/baofeng_uv3r.py
--- a/chirp/baofeng_uv3r.py Wed Jan 21 23:30:19 2015 -0800
+++ b/chirp/baofeng_uv3r.py Thu Jan 22 20:53:37 2015 -0800
@@ -421,42 +421,6 @@
                                         CH_FLAG_LIST[_settings.ch_flag]))
         basic.append(rs)
 
-        _limit = int(self._memobj.limits.lower_vhf) / 10
-        rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (115-239 MHz)",
-                          RadioSettingValueInteger(115, 235, _limit))
-        def apply_limit(setting, obj):
-            value = int(setting.value) * 10
-            obj.lower_vhf = value
-        rs.set_apply_callback(apply_limit, self._memobj.limits)
-        basic.append(rs)
-
-        _limit = int(self._memobj.limits.upper_vhf) / 10
-        rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (115-239 MHz)",
-                          RadioSettingValueInteger(115, 235, _limit))
-        def apply_limit(setting, obj):
-            value = int(setting.value) * 10
-            obj.upper_vhf = value
-        rs.set_apply_callback(apply_limit, self._memobj.limits)
-        basic.append(rs)
-
-        _limit = int(self._memobj.limits.lower_uhf) / 10
-        rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (200-529 MHz)",
-                          RadioSettingValueInteger(200, 529, _limit))
-        def apply_limit(setting, obj):
-            value = int(setting.value) * 10
-            obj.lower_uhf = value
-        rs.set_apply_callback(apply_limit, self._memobj.limits)
-        basic.append(rs)
-
-        _limit = int(self._memobj.limits.upper_uhf) / 10
-        rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (200-529 MHz)",
-                          RadioSettingValueInteger(200, 529, _limit))
-        def apply_limit(setting, obj):
-            value = int(setting.value) * 10
-            obj.upper_uhf = value
-        rs.set_apply_callback(apply_limit, self._memobj.limits)
-        basic.append(rs)
-
         vfo_preset = RadioSettingGroup("vfo_preset", "VFO Presets")
         group.append(vfo_preset)
 
diff -r b25606106a9c -r e347fdbfc9c2 tests/run_tests
--- a/tests/run_tests Wed Jan 21 23:30:19 2015 -0800
+++ b/tests/run_tests Thu Jan 22 20:53:37 2015 -0800
@@ -520,8 +520,30 @@
         self.do_badname(rf)
 
         return []
+
 TESTS["Edges"] = TestCaseEdges
 
+
+class TestCaseSettings(TestCase):
+    def __str__(self):
+        return "Settings"
+
+    def do_get_settings(self, rf):
+        self._wrapper.do("get_settings")
+
+    def run(self):
+        rf = self._wrapper.do("get_features")
+
+        if not rf.has_settings:
+            raise TestSkippedError("Settings not supported")
+
+ self.do_get_settings(rf)
+
+        return []
+
+TESTS["Settings"] = TestCaseSettings
+
+
 class TestCaseBanks(TestCase):
     def __str__(self):
         return "Banks"