Пример #1
0
 def _create_omf_objects(self, raw_data, config_category_name, type_id):
     """ Handles the creation of the OMF types related to the asset codes using one of the 2 possible ways :
             Automatic OMF Type Mapping
             Configuration Based OMF Type Mapping
     Args:
         raw_data :            data block to manage as retrieved from the Storage layer
         config_category_name: used to identify OMF objects already created
         type_id:              used to identify OMF objects already created
     Returns:
     Raises:
     Todo:
     """
     asset_codes_to_evaluate = plugin_common.identify_unique_asset_codes(raw_data)
     asset_codes_already_created = self._retrieve_omf_types_already_created(config_category_name, type_id)
     for item in asset_codes_to_evaluate:
         asset_code = item["asset_code"]
         # Evaluates if it is a new OMF type
         if not any(tmp_item == asset_code for tmp_item in asset_codes_already_created):
             asset_code_omf_type = ""
             try:
                 asset_code_omf_type = copy.deepcopy(_config_omf_types[asset_code]["value"])
             except KeyError:
                 configuration_based = False
             else:
                 configuration_based = True
             if configuration_based:
                 _logger.debug("creates type - configuration based - asset |{0}| ".format(asset_code))
                 self._create_omf_objects_configuration_based(asset_code, asset_code_omf_type)
             else:
                 # handling - Automatic OMF Type Mapping
                 _logger.debug("creates type - automatic handling - asset |{0}| ".format(asset_code))
                 self._create_omf_objects_automatic(item)
             self._flag_created_omf_type(config_category_name, type_id, asset_code)
         else:
             _logger.debug("asset already created - asset |{0}| ".format(asset_code))
Пример #2
0
    def test_identify_unique_asset_codes(self, value, expected):
        """ """

        assert plugin_common.identify_unique_asset_codes(value) == expected