def test_xmi_simdd_attribute_parameters_when_both_specified(self): """Testing attribute parameters when both xmi and simdd are specified. Check whether the attribute parameters specified in the xmi and simdd files are properly parsed to the device and also ensuring that those of the simdd override the ones in xmi in the configured model """ attr_with_overrriden_info = 'temperature' simdd_specified_temperature_attr_params = { 'description': 'Current actual ' 'temperature outside near the telescope.', 'min_value': '-15', 'max_value': '55' } for data_file in self.data_descr_files: if '.xmi' in data_file.lower(): xmi_parser = sim_xmi_parser.XmiParser() xmi_parser.parse(data_file) expected_device_attr_xmi_info = ( xmi_parser.get_reformatted_device_attr_metadata()) expected_device_temperature_attr_overridden_info = dict( expected_device_attr_xmi_info[attr_with_overrriden_info], **simdd_specified_temperature_attr_params) # Creating a copy of the attribute info as specified in the xmi and # overriding it with that specified in the simdd then create a # structure of what is expected as a result of the combination of the two. expected_device_attr_xmi_info_copy = expected_device_attr_xmi_info.copy( ) expected_device_attr_xmi_info_copy[attr_with_overrriden_info] = ( expected_device_temperature_attr_overridden_info) expected_device_attr_xmi_overridden = ( expected_device_attr_xmi_info_copy) sim_quantities = self.instance.model.sim_quantities for expected_quantity in expected_device_attr_xmi_info.keys(): self.assertIn( expected_quantity, sim_quantities, "The attribute {} is not in the parsed " "attribute list".format(expected_quantity)) actual_device_attr_info = sim_quantities[expected_quantity].meta for prop in expected_device_attr_xmi_info[expected_quantity]: # The 'inherited' parameter is not part of the Tango device attribute # properties. if prop == 'inherited': continue if prop not in simdd_specified_temperature_attr_params.keys(): self.assertEquals( expected_device_attr_xmi_info[expected_quantity][prop], actual_device_attr_info[prop], "The {} quantity expected value for the parameter " "'{}' does not match with the actual value in the " "device model".format(expected_quantity, prop)) self.assertEquals( expected_device_attr_xmi_overridden[expected_quantity] [prop], actual_device_attr_info[prop], "The {} quantity expected value for the overridden " "parameter '{}' does not match with the actual value " "in the device model".format(expected_quantity, prop))
def setUp(self): super(test_TangoSimGenDeviceIntegration, self).setUp() self.xmi_parser = sim_xmi_parser.XmiParser() self.xmi_parser.parse(self.data_descr_file[0]) self.expected_model = tango_sim_generator.configure_device_model( self.data_descr_file, self.sim_device.name()) self.attr_name_enum_labels = sorted( self.sim_control_device.attribute_query( 'attribute_name').enum_labels)
def test_xmi_simdd_command_parameters_when_both_specified(self): """Testing command parameters when both xmi and simdd are specified. Check whether the command parameters specified in the xmi and simdd files are properly parsed to the device and also ensuring that those of the simdd override the ones in xmi in the configured model """ cmd_with_overrriden_info = 'On' simdd_specified_on_cmd_params = { 'doc_in': 'No input parameter required', 'doc_out': 'Command responds only' } for data_file in self.data_descr_files: if '.xmi' in data_file.lower(): xmi_parser = sim_xmi_parser.XmiParser() xmi_parser.parse(data_file) expected_device_cmd_xmi_info = ( xmi_parser.get_reformatted_cmd_metadata()) expected_device_on_cmd_overridden_info = dict( expected_device_cmd_xmi_info[cmd_with_overrriden_info], **simdd_specified_on_cmd_params) # Creating a copy of the command info as specified in the xmi and # overriding it with that specified in the simdd then create a # structure of what is expected as a result of the combination of the two. expected_device_cmd_xmi_info_copy = expected_device_cmd_xmi_info.copy() expected_device_cmd_xmi_info_copy[cmd_with_overrriden_info] = ( expected_device_on_cmd_overridden_info) expected_device_cmd_xmi_overridden = ( expected_device_cmd_xmi_info_copy) sim_actions = self.instance.model.sim_actions_meta for expected_action in expected_device_cmd_xmi_info.keys(): if expected_action not in helper_module.DEFAULT_TANGO_DEVICE_COMMANDS: self.assertIn( expected_action, sim_actions.keys(), "The command {} is not in the parsed " "command list".format(expected_action)) actual_device_attr_info = sim_actions[expected_action] for prop in expected_device_cmd_xmi_info[expected_action]: # The 'inherited' parameter is not part of the Tango device attribute # properties. if prop == 'inherited': continue if prop not in simdd_specified_on_cmd_params.keys(): self.assertEquals( expected_device_cmd_xmi_info[expected_action] [prop], actual_device_attr_info[prop], "The {} action expected value for the parameter " "'{}' does not match with the actual value in the " "device model".format(expected_action, prop)) self.assertEquals( expected_device_cmd_xmi_overridden[expected_action] [prop], actual_device_attr_info[prop], "The {} action expected value for the overridden " "parameter '{}' does not match with the actual value " "in the device model".format(expected_action, prop))
def setUp(self): super(test_SourceSimulatorInfo, self).setUp() self.sim_xmi_file = [ pkg_resources.resource_filename('tango_simlib.tests', 'MkatVds.xmi') ] self.simdd_json_file = [ pkg_resources.resource_filename('tango_simlib.tests', 'MkatVds_SIMDD.json') ] self.simdd_parser = simdd_json_parser.SimddParser() self.xmi_parser = sim_xmi_parser.XmiParser() self.xmi_parser.parse(self.sim_xmi_file[0]) self.simdd_parser.parse(self.simdd_json_file[0])
# Find the xmi files in the repo and store their paths output = subprocess.check_output(["kat-search.py -f *.xmi"], shell=True) # Create a list of of all the file paths. strings = output.split("\n") # Remove the string "DEFAULT", which is always the first output of 'kat-search.py'. strings.remove("DEFAULTS") # Create a csv file object. with open("csv_file.csv", 'wb') as myfile: wr = csv.writer(myfile, quoting=csv.QUOTE_ALL) print csv.QUOTE_ALL for fiel in strings: xmi_parser = sim_xmi_parser.XmiParser() try: xmi_parser.parse(fiel) except AttributeError: continue print fiel attr_info = xmi_parser.get_reformatted_device_attr_metadata() #cmd_info = xmi_parser.get_reformatted_cmd_metadata() #dev_props = xmi_parser.get_reformatted_properties_metadata('deviceProperties') #class_props = xmi_parser.get_reformatted_properties_metadata('classProperties') for attr_name, attr_props in attr_info.items(): print attr_props break
def setUp(self): super(test_XmiStaticAttributes, self).setUp() self.device = self.tango_context.device self.instance = self.TangoDeviceServer.instances[self.device.name()] self.xmi_parser = sim_xmi_parser.XmiParser() self.xmi_parser.parse(self.xmi_file[0])
def setUp(self): super(GenericSetup, self).setUp() self.xmi_file = [pkg_resources.resource_filename('tango_simlib.tests', 'Weather.xmi')] self.xmi_parser = sim_xmi_parser.XmiParser() self.xmi_parser.parse(self.xmi_file[0])
def setUp(self): super(test_SimXmiDeviceIntegration, self).setUp() self.device = self.tango_context.device self.instance = self.TangoDeviceServer.instances[self.device.name()] self.xmi_parser = sim_xmi_parser.XmiParser() self.xmi_parser.parse(self.xmi_file[0])
if __name__ == '__main__': # Find the xmi files in the repo and store their paths filepaths = [] for root, dirnames, filenames in os.walk(args.path): # Only process xmi files for filename in fnmatch.filter(filenames, "*.xmi"): # Append for processing if it matches the files pattern if fnmatch.filter([filename], args.files): print "Found", os.path.join(root, filename) filepaths.append(os.path.join(root, filename)) for filepath in sorted(filepaths): # Create a parser instance for the XMI file to be pruned. print "File to prune: ", filepath psr = sim_xmi_parser.XmiParser() psr.parse(filepath) # Get all the features of the TANGO class attr_qualities = psr.get_reformatted_device_attr_metadata() cmd_qualities = psr.get_reformatted_cmd_metadata() devprop_qualities = psr.get_reformatted_properties_metadata('deviceProperties') clsprop_qualities = psr.get_reformatted_properties_metadata('classProperties') # Get the closest parent class. cls_descr = psr.class_description super_classes = cls_descr.values()[0] # Remove the 'Device_Impl' class information super_class_info = [item for item in super_classes if not item["classname"].startswith("Device_Impl")] super_class_info.reverse()