def apply_to_invalid_data_test(self): data = self.InvalidData() self.assertEqual(data.x, 0) with self.assertRaises(DBusStructureError) as cm: get_structure(data) self.assertEqual(str(cm.exception), """Fields are not defined at '__dbus_fields__'.""")
def get_simple_structure_test(self): data = self.SimpleData() self.assertEqual(data.x, 0) structure = get_structure(data) self.assertEqual(structure, {'x': get_variant(Int, 0)}) data.x = 10 self.assertEqual(data.x, 10) structure = get_structure(data) self.assertEqual(structure, {'x': get_variant(Int, 10)})
def GetSupportedDevices(self) -> List[Structure]: """Get info about existing network devices supported by the module. :return: list of objects describing supported devices found on the system """ dev_infos = self.implementation.get_supported_devices() return [get_structure(dev_info) for dev_info in dev_infos]
def GetDeviceData(self, name: Str) -> Structure: """Get the device data. :param name: a device name :return: a structure with device data :raise: UnknownDeviceError if the device is not found """ return get_structure(self.implementation.get_device_data(name))
def get_complicated_structure_test(self): data = self.ComplicatedData() data.dictionary = {1: "1", 2: "2"} data.bool_list = [True, False, False] data.very_long_property_name = "My String Value" self.assertEqual( { 'dictionary': get_variant(Dict[Int, Str], {1: "1", 2: "2"}), 'bool-list': get_variant(List[Bool], [True, False, False]), 'very-long-property-name': get_variant(Str, "My String Value") }, get_structure(data) )
def get_complicated_structure_test(self): data = self.ComplicatedData() data.dictionary = {1: "1", 2: "2"} data.bool_list = [True, False, False] data.very_long_property_name = "My String Value" self.assertEqual( { 'dictionary': get_variant(Dict[Int, Str], { 1: "1", 2: "2" }), 'bool-list': get_variant(List[Bool], [True, False, False]), 'very-long-property-name': get_variant(Str, "My String Value") }, get_structure(data))
def GetDeviceConfigurations(self) -> List[Structure]: """Get the state of network devices configuration. Contains only configuration of devices supported by Anaconda. Returns list of NetworkDeviceConfiguration objects holding configuration of a network device. For a physical device there is only single NetworkDeviceConfiguration object bound to the device name (the mandatory persistent element of the object). The uuid corresponds to the configuration of the device for installed system. For a virtual device there can be multiple NetworkDeviceConfiguration objects, bound to uuid of the device configuration (the mandatory persistent element of the object). The device name is set in the object only if there exists respective active device with the configuration given by uuid applied. Configurations correspond to NetworkManager persistent connections by their uuid. """ dev_cfgs = self.implementation.get_device_configurations() return [get_structure(dev_cfg) for dev_cfg in dev_cfgs]
def Realm(self) -> Structure: """Specification of the enrollment in a realm. :return: a dictionary with a specification """ return get_structure(self.implementation.realm)
def _device_configurations_changed(self, changes): self.DeviceConfigurationChanged([ (get_structure(old), get_structure(new)) for old, new in changes ])
def skip_members_test(self): structure = get_structure(self.SkipData()) self.assertEqual(structure, {'x': get_variant(Int, 0)}) data = apply_structure({'x': 10}, self.SkipData()) self.assertEqual(data.x, 10)