From eb6306eb03f44cc8d61b7af724f4cff1b221559a Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Fri, 10 Aug 2018 01:31:14 +0000 Subject: [PATCH] web: fix job required-projects list The required-project is a dictionary and the model needs to convert the values instead of the keys. Change-Id: I6e26fe5f85ff8e337d447567a58042a06881d0d1 --- .../single-tenant/git/common-config/zuul.yaml | 6 ++++ tests/unit/test_web.py | 31 ++++++++++++++++++- zuul/model.py | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml b/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml index 230745f79a..750d578ec0 100644 --- a/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml +++ b/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml @@ -189,3 +189,9 @@ dependencies: project-merge - project1-project2-integration: dependencies: project-merge + +- job: + name: test-job + run: playbooks/project-merge.yaml + required-projects: + - org/project diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py index 7bb08c4104..2aaccc7e0b 100755 --- a/tests/unit/test_web.py +++ b/tests/unit/test_web.py @@ -342,6 +342,35 @@ class TestWeb(BaseTestWeb): 'voting': True }], data) + data = self.get_url('api/tenant/tenant-one/job/test-job').json() + self.assertEqual([ + { + 'abstract': False, + 'attempts': 3, + 'branches': [], + 'dependencies': [], + 'description': None, + 'files': [], + 'final': False, + 'implied_branch': None, + 'irrelevant_files': [], + 'name': 'test-job', + 'parent': 'base', + 'post_review': None, + 'protected': None, + 'required_projects': [ + {'override_branch': None, + 'override_checkout': None, + 'project_name': 'review.example.com/org/project'}], + 'roles': [common_config_role], + 'semaphore': None, + 'source_context': source_ctx, + 'timeout': None, + 'variables': {}, + 'variant_description': '', + 'voting': True + }], data) + def test_web_keys(self): with open(os.path.join(FIXTURE_DIR, 'public.pem'), 'rb') as f: public_pem = f.read() @@ -362,7 +391,7 @@ class TestWeb(BaseTestWeb): def test_jobs_list(self): jobs = self.get_url("api/tenant/tenant-one/jobs").json() - self.assertEqual(len(jobs), 8) + self.assertEqual(len(jobs), 9) resp = self.get_url("api/tenant/non-tenant/jobs") self.assertEqual(404, resp.status_code) diff --git a/zuul/model.py b/zuul/model.py index 8f5b761914..a4d071511b 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -1110,7 +1110,7 @@ class Job(ConfigObject): d['source_context'] = self.source_context.toDict() d['description'] = self.description d['required_projects'] = [] - for project in self.required_projects: + for project in self.required_projects.values(): d['required_projects'].append(project.toDict()) d['semaphore'] = self.semaphore d['variables'] = self.variables