diff --git a/osbs/repo_utils.py b/osbs/repo_utils.py index a6b67ab63..a01457ec6 100644 --- a/osbs/repo_utils.py +++ b/osbs/repo_utils.py @@ -20,7 +20,15 @@ logger = logging.getLogger(__name__) -RepoInfo = namedtuple('RepoInfo', 'dockerfile_parser, configuration, additional_tags') +class RepoInfo(object): + """ + Aggregator for different aspects of the repository. + """ + + def __init__(self, dockerfile_parser=None, configuration=None, additional_tags=None): + self.dockerfile_parser = dockerfile_parser + self.configuration = configuration or RepoConfiguration() + self.additional_tags = additional_tags or AdditionalTagsConfig() class RepoConfiguration(object): diff --git a/tests/build_/test_arrangements.py b/tests/build_/test_arrangements.py index ce9d43c8a..b26ef77a1 100644 --- a/tests/build_/test_arrangements.py +++ b/tests/build_/test_arrangements.py @@ -12,7 +12,7 @@ ORCHESTRATOR_INNER_TEMPLATE, WORKER_INNER_TEMPLATE) from osbs import utils -from osbs.repo_utils import RepoInfo, RepoConfiguration, AdditionalTagsConfig +from osbs.repo_utils import RepoInfo from tests.constants import (TEST_GIT_URI, TEST_GIT_REF, TEST_GIT_BRANCH, @@ -46,7 +46,7 @@ class MockParser(object): (flexmock(utils) .should_receive('get_repo_info') .with_args(TEST_GIT_URI, TEST_GIT_REF, git_branch=TEST_GIT_BRANCH) - .and_return(RepoInfo(MockParser(), RepoConfiguration(), AdditionalTagsConfig()))) + .and_return(RepoInfo(MockParser()))) # Trick create_orchestrator_build into return the *request* JSON flexmock(OSBS, _create_build_config_and_build=request_as_response) diff --git a/tests/build_/test_build_request.py b/tests/build_/test_build_request.py index 350204c84..e25e55a27 100644 --- a/tests/build_/test_build_request.py +++ b/tests/build_/test_build_request.py @@ -1766,7 +1766,7 @@ class MockDfParser(object): .should_receive('is_autorebuild_enabled') .and_return(autorebuild_enabled)) - repo_info = RepoInfo(MockDfParser(), RepoConfiguration(), AdditionalTagsConfig()) + repo_info = RepoInfo(MockDfParser()) build_request_kwargs = get_sample_prod_params() base_image = build_request_kwargs['base_image'] diff --git a/tests/test_api.py b/tests/test_api.py index 7d6be8d82..214690104 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -41,7 +41,7 @@ ORCHESTRATOR_CUSTOMIZE_CONF, BUILD_TYPE_WORKER, BUILD_TYPE_ORCHESTRATOR) from osbs import utils -from osbs.repo_utils import RepoInfo, RepoConfiguration, AdditionalTagsConfig +from osbs.repo_utils import RepoInfo from tests.constants import (TEST_ARCH, TEST_BUILD, TEST_COMPONENT, TEST_GIT_BRANCH, TEST_GIT_REF, TEST_GIT_URI, TEST_TARGET, TEST_USER, INPUTS_PATH, @@ -87,7 +87,7 @@ class TestOSBS(object): def mock_repo_info(self, mock_df_parser=None): mock_df_parser = mock_df_parser or MockDfParser() - return RepoInfo(mock_df_parser, RepoConfiguration(), AdditionalTagsConfig()) + return RepoInfo(mock_df_parser) def test_osbsapi_wrapper(self): """ diff --git a/tests/test_repo_utils.py b/tests/test_repo_utils.py index 63ca03022..4186fba6e 100644 --- a/tests/test_repo_utils.py +++ b/tests/test_repo_utils.py @@ -6,14 +6,34 @@ of the BSD license. See the LICENSE file for details. """ +from flexmock import flexmock from osbs.constants import REPO_CONFIG_FILE, ADDITIONAL_TAGS_FILE -from osbs.repo_utils import RepoConfiguration, AdditionalTagsConfig +from osbs.repo_utils import RepoInfo, RepoConfiguration, AdditionalTagsConfig from textwrap import dedent import os import pytest +class TestRepoInfo(object): + + def test_default_params(self): + repo_info = RepoInfo() + assert repo_info.dockerfile_parser is None + assert isinstance(repo_info.configuration, RepoConfiguration) + assert isinstance(repo_info.additional_tags, AdditionalTagsConfig) + + def test_explicit_params(self): + df_parser = flexmock() + configuration = RepoConfiguration() + tags_config = AdditionalTagsConfig() + + repo_info = RepoInfo(df_parser, configuration, tags_config) + assert repo_info.dockerfile_parser is df_parser + assert repo_info.configuration is configuration + assert repo_info.additional_tags is tags_config + + class TestRepoConfiguration(object): def test_default_values(self):