Esempio n. 1
0
 def test_radio_setting_multi(self):
     val1 = settings.RadioSettingValueBoolean(True)
     val2 = settings.RadioSettingValueBoolean(False)
     rs = settings.RadioSetting("foo", "Foo", val1, val2)
     self.assertEqual(rs[0], val1)
     self.assertEqual(rs[1], val2)
     rs[0] = False
     rs[1] = True
     self.assertEqual(val1.get_value(), False)
     self.assertEqual(val2.get_value(), True)
Esempio n. 2
0
    def test_radio_setting_group(self):
        s1 = settings.RadioSetting("s1", "Setting 1")
        s2 = settings.RadioSetting("s2", "Setting 2")
        s3 = settings.RadioSetting("s3", "Setting 3")
        group = settings.RadioSettingGroup("foo", "Foo Group", s1)
        self.assertEqual(group.get_name(), "foo")
        self.assertEqual(group.get_shortname(), "Foo Group")
        self.assertEqual(group.values(), [s1])
        self.assertEqual(group.keys(), ["s1"])
        group.append(s2)
        self.assertEqual(group.items(), [("s1", s1), ("s2", s2)])
        self.assertEqual(group["s1"], s1)
        group["s3"] = s3
        self.assertEqual(group.values(), [s1, s2, s3])
        self.assertEqual(group.keys(), ["s1", "s2", "s3"])
        self.assertEqual([x for x in group], [s1, s2, s3])

        def set_dupe():
            group["s3"] = s3
        self.assertRaises(KeyError, set_dupe)
Esempio n. 3
0
    def test_apply_callback(self):
        class TestException(Exception):
            pass

        rs = settings.RadioSetting("foo", "Foo")
        self.assertFalse(rs.has_apply_callback())

        def test_cb(setting, data1, data2):
            self.assertEqual(setting, rs)
            self.assertEqual(data1, "foo")
            self.assertEqual(data2, "bar")
            raise TestException()
        rs.set_apply_callback(test_cb, "foo", "bar")
        self.assertTrue(rs.has_apply_callback())
        self.assertRaises(TestException, rs.run_apply_callback)
Esempio n. 4
0
 def test_radio_setting(self):
     val = settings.RadioSettingValueBoolean(True)
     rs = settings.RadioSetting("foo", "Foo", val)
     self.assertEqual(rs.value, val)
     rs.value = False
     self.assertEqual(val.get_value(), False)