def _generate_type_map():
    '''Generate TOSCA translation types map.

    Load user defined classes from location path specified in conf file.
    Base classes are located within the tosca directory.

    '''

    # Base types directory
    BASE_PATH = 'translator/hot/tosca'

    # Custom types directory defined in conf file
    custom_path = translatorConfig.get_value('DEFAULT',
                                             'custom_types_location')

    # First need to load the parent module, for example 'contrib.hot',
    # for all of the dynamically loaded classes.
    _load_custom_mod(custom_path)
    classes = []
    _load_classes((BASE_PATH, custom_path), classes)
    try:
        types_map = {clazz.toscatype: clazz for clazz in classes}
    except AttributeError as e:
        raise ToscaClassAttributeError(message=e.message)

    return types_map
def _generate_type_map():
    '''Generate TOSCA translation types map.

    Load user defined classes from location path specified in conf file.
    Base classes are located within the tosca directory.

    '''

    # Base types directory
    BASE_PATH = 'translator/hot/tosca'

    # Custom types directory defined in conf file
    custom_path = translatorConfig.get_value('DEFAULT',
                                             'custom_types_location')

    # First need to load the parent module, for example 'contrib.hot',
    # for all of the dynamically loaded classes.
    classes = []
    _load_classes((BASE_PATH, custom_path), classes)
    try:
        types_map = {clazz.toscatype: clazz for clazz in classes}
    except AttributeError as e:
        raise ToscaClassAttributeError(message=e.message)

    return types_map
示例#3
0
 def test_get_value(self):
     ret_value = mock.MagicMock(return_value='hot')
     translatorConfig._translator_config.get = ret_value
     value = translatorConfig.get_value('DEFAULT', 'language')
     self.assertTrue(translatorConfig._translator_config.get.called)
     self.assertEqual(value, 'hot')
示例#4
0
 def test_get_value(self, mock_translator_config):
     mock_translator_config.return_value = 'hot'
     value = translatorConfig.get_value('DEFAULT', 'language')
     self.assertTrue(translatorConfig._translator_config.get.called)
     self.assertEqual(value, 'hot')
示例#5
0
 def test_get_value(self):
     ret_value = mock.MagicMock(return_value='hot')
     translatorConfig._translator_config.get = ret_value
     value = translatorConfig.get_value('DEFAULT', 'language')
     self.assertTrue(translatorConfig._translator_config.get.called)
     self.assertEqual(value, 'hot')