From 19d828cbd7ea47857156a61976a20d8bf9deedde Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Feb 02 2018 08:01:44 +0000 Subject: Use compose.odcs_compose_id instead of compose.id in get_repo_urls. --- diff --git a/freshmaker/handlers/__init__.py b/freshmaker/handlers/__init__.py index 07d7181..b283371 100644 --- a/freshmaker/handlers/__init__.py +++ b/freshmaker/handlers/__init__.py @@ -414,7 +414,7 @@ class ContainerBuildHandler(BaseHandler): :return: list of repository URLs. :rtype: list """ - return [self.odcs_get_compose(rel.compose.id)['result_repofile'] + return [self.odcs_get_compose(rel.compose.odcs_compose_id)['result_repofile'] for rel in build.composes] def start_to_build_images(self, builds): diff --git a/tests/test_handler.py b/tests/test_handler.py index 11dc56c..5eb25bf 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -135,10 +135,10 @@ class TestGetRepoURLs(helpers.ModelsTestCase): def setUp(self): super(TestGetRepoURLs, self).setUp() - self.compose_1 = Compose(odcs_compose_id=1) - self.compose_2 = Compose(odcs_compose_id=2) - self.compose_3 = Compose(odcs_compose_id=3) - self.compose_4 = Compose(odcs_compose_id=4) + self.compose_1 = Compose(odcs_compose_id=5) + self.compose_2 = Compose(odcs_compose_id=6) + self.compose_3 = Compose(odcs_compose_id=7) + self.compose_4 = Compose(odcs_compose_id=8) db.session.add(self.compose_1) db.session.add(self.compose_2) db.session.add(self.compose_3) @@ -173,26 +173,15 @@ class TestGetRepoURLs(helpers.ModelsTestCase): db.session.commit() + def mocked_odcs_get_compose(compose_id): + return { + "id": compose_id, + "result_repofile": "http://localhost/%d.repo" % compose_id, + } + self.patch_odcs_get_compose = patch( "freshmaker.handlers.ContainerBuildHandler.odcs_get_compose", - side_effect=[ - { - "id": self.compose_1.id, - "result_repofile": "http://localhost/1.repo", - }, - { - "id": self.compose_2.id, - "result_repofile": "http://localhost/2.repo", - }, - { - "id": self.compose_3.id, - "result_repofile": "http://localhost/3.repo", - }, - { - "id": self.compose_4.id, - "result_repofile": "http://localhost/4.repo", - }, - ]) + side_effect=mocked_odcs_get_compose) self.odcs_get_compose = self.patch_odcs_get_compose.start() def tearDown(self): @@ -209,10 +198,10 @@ class TestGetRepoURLs(helpers.ModelsTestCase): repos = handler.get_repo_urls(self.build_1) self.assertEqual( [ - 'http://localhost/1.repo', - 'http://localhost/2.repo', - 'http://localhost/3.repo', - 'http://localhost/4.repo', + 'http://localhost/5.repo', + 'http://localhost/6.repo', + 'http://localhost/7.repo', + 'http://localhost/8.repo', ], sorted(repos))