Exemplo n.º 1
0
    def test_version_manager_get_current_return_current_version_id(self):
        # Arrange
        mock_version_manager = _create_mock_version_manager()

        # Act
        result = version_manager_api.get_current(mock_version_manager)

        # Assert
        self.assertEquals(result, mock_version_manager.current)
Exemplo n.º 2
0
def get_current_registry_template():
    """ Get the current template used for the registry.

    Returns:
        Template:

    """
    try:
        template_version = version_manager_api.\
            get_active_global_version_manager_by_title(REGISTRY_XSD_FILENAME)
        return template_api.get(
            version_manager_api.get_current(template_version))
    except Exception, e:
        raise exceptions.ModelError(e.message)
Exemplo n.º 3
0
def _get_current_template():
    """Get the current template.

    Returns:
    """
    current_template_version = (
        version_manager_api.get_active_global_version_manager_by_title(
            REGISTRY_XSD_FILENAME
        )
    )
    current_template = template_api.get(
        version_manager_api.get_current(current_template_version)
    )
    return current_template
Exemplo n.º 4
0
def _init_custom_registry():
    """Init the custom registry.

    Returns:
    """

    try:
        current_template_version = (
            version_manager_api.get_active_global_version_manager_by_title(
                REGISTRY_XSD_FILENAME))
        current_template = template_api.get(
            version_manager_api.get_current(current_template_version))
    except:
        raise Exception("Can't get the current template.")

    if len(custom_resource_api.get_all_by_template(current_template)) > 0:
        print('**********')
        print(custom_resource_api.get_all_by_template(current_template))
        print('**********')
        logger.info(
            "Custom resources related to current template already exist.")
    else:
        json_path = CUSTOM_REGISTRY_FILE_PATH
        if json_path == "":
            raise Exception(
                "Please configure the CUSTOM_REGISTRY_FILE_PATH setting in your project."
            )

        try:
            default_json_path = finders.find(json_path)
            with open(default_json_path) as json_file:
                data = json.load(json_file)
                print('**********')
                print(f'parsing json: {data}')
                print('**********')
                custom_resource_api.parse_and_save(data, current_template)
        except Exception as e:
            logger.error(
                "Impossible to use the custom registry json file: {0}".format(
                    str(e)))