777
777
self.__dbus_object_path__ = "objpath_{}".format(name)
778
778
self.attributes = attributes
779
779
self.attributes["Name"] = name
780
def Set(interface, property, value,
781
properties_interface):
781
def Set(self, interface, property, value, dbus_interface):
782
782
testcase.assertEqual(interface, client_interface)
783
testcase.assertEqual(properties_interface,
783
testcase.assertEqual(dbus_interface,
784
784
dbus.PROPERTIES_IFACE)
785
785
self.attributes[property] = value
786
def Get(interface, property, properties_interface):
786
self.calls.append(("Set", (interface, property, value,
788
def Get(self, interface, property, dbus_interface):
787
789
testcase.assertEqual(interface, client_interface)
788
testcase.assertEqual(properties_interface,
790
testcase.assertEqual(dbus_interface,
789
791
dbus.PROPERTIES_IFACE)
792
self.calls.append(("Get", (interface, property,
790
794
return self.attributes[property]
791
795
def __getitem__(self, key):
792
796
return self.attributes[key]
797
def __setitem__(self, key, value):
798
self.attributes[key] = value
793
799
self.clients = collections.OrderedDict([
930
936
expected_json = {"foo": self.expected_json["foo"]}
931
937
self.assertDictEqual(json_data, expected_json)
939
class TestIsEnabledCmd(TestCmd):
940
def test_is_enabled(self):
941
self.assertTrue(all(IsEnabledCmd().is_enabled(client)
942
for client in self.clients.values()))
943
def test_is_enabled_does_get_attribute(self):
944
client = self.clients["foo"]
945
self.assertTrue(IsEnabledCmd().is_enabled(client))
946
self.assertListEqual(client.calls,
948
("se.recompile.Mandos.Client",
950
"org.freedesktop.DBus.Properties"))])
951
def test_is_enabled_run_exits_successfully(self):
952
client = self.clients["foo"]
953
with self.assertRaises(SystemExit) as e:
954
IsEnabledCmd().run_on_one_client(client)
955
if e.exception.code is not None:
956
self.assertEqual(e.exception.code, 0)
958
self.assertIsNone(e.exception.code)
959
def test_is_enabled_run_exits_with_failure(self):
960
client = self.clients["foo"]
961
client["Enabled"] = dbus.Boolean(False)
962
with self.assertRaises(SystemExit) as e:
963
IsEnabledCmd().run_on_one_client(client)
964
if isinstance(e.exception.code, int):
965
self.assertNotEqual(e.exception.code, 0)
967
self.assertIsNotNone(e.exception.code)
934
971
def should_only_run_tests():
935
972
parser = argparse.ArgumentParser(add_help=False)