From 6d813d14d351f4ad3ae7cff991b8af7a1549d67e Mon Sep 17 00:00:00 2001 From: gaspardmoindrot Date: Wed, 26 Jul 2023 20:45:32 +0000 Subject: [PATCH] =?UTF-8?q?[PTFE-583]=20=E2=9C=A8=20Prevent=20creation=20o?= =?UTF-8?q?f=20integration=20branches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bert_e/tests/test_bert_e.py | 18 +++++++++++------- bert_e/workflow/gitwaterflow/integration.py | 12 ++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bert_e/tests/test_bert_e.py b/bert_e/tests/test_bert_e.py index eee29f2e..cac58da8 100644 --- a/bert_e/tests/test_bert_e.py +++ b/bert_e/tests/test_bert_e.py @@ -1250,14 +1250,15 @@ def test_request_integration_branch_by_creating_pull_requests(self): pr.id, settings=settings, options=options, backtrace=True) self.assertEqual(len(list(pr.get_comments())), 4) self.assertIn('Integration data created', self.get_last_pr_comment(pr)) - + options = self.bypass_all with self.assertRaises(exns.SuccessMessage): self.handle( pr.id, settings=settings, options=options, backtrace=True) self.assertIn( - 'I have successfully merged the changeset', self.get_last_pr_comment(pr)) + 'I have successfully merged the changeset', + self.get_last_pr_comment(pr)) def test_creation_integration_branch_by_approve(self): """Test pr.approve() to request integration branches creation. @@ -1291,19 +1292,21 @@ def test_creation_integration_branch_by_approve(self): prs = [pr_1, pr_2] for pr in prs: - options = self.bypass_all_but(['bypass_build_status', 'bypass_author_approval']) + options = self.bypass_all_but(['bypass_build_status', + 'bypass_author_approval']) with self.assertRaises(exns.ApprovalRequired): self.handle(pr.id, options=options, backtrace=True) self.assertEqual(len(list(pr.get_comments())), 3) self.assertIn( - 'Integration data created', list(pr.get_comments())[-2].text) + 'Integration data created', list(pr.get_comments())[-2].text) self.assertIn( 'Waiting for approval', self.get_last_pr_comment(pr)) self.assertIn( - 'The following approvals are needed', self.get_last_pr_comment(pr)) + 'The following approvals are needed', + self.get_last_pr_comment(pr)) if pr.src_branch == "feature/TEST-0069": pr.approve() @@ -1318,9 +1321,10 @@ def test_creation_integration_branch_by_approve(self): with self.assertRaises(exns.SuccessMessage): self.handle( pr.id, settings=settings, options=options, backtrace=True) - + self.assertIn( - 'I have successfully merged the changeset', self.get_last_pr_comment(pr)) + 'I have successfully merged the changeset', + self.get_last_pr_comment(pr)) def test_integration_branch_creation_latest_branch(self): """Test there is no comment to request integration branches creation. diff --git a/bert_e/workflow/gitwaterflow/integration.py b/bert_e/workflow/gitwaterflow/integration.py index 52488333..7817bcba 100644 --- a/bert_e/workflow/gitwaterflow/integration.py +++ b/bert_e/workflow/gitwaterflow/integration.py @@ -145,15 +145,15 @@ def check_integration_branches(job): approved_by_author = job.pull_request.author in approvals create_integration = (job.settings.always_create_integration_branches or - job.settings.create_integration_branches) + job.settings.create_integration_branches) create_prs = (job.settings.always_create_integration_pull_requests or - job.settings.create_pull_requests) + job.settings.create_pull_requests) multiple_dst_branches = len(job.git.cascade.dst_branches) <= 1 - if not (create_integration - or create_prs - or approved_by_author - or multiple_dst_branches): + if not (create_integration or + create_prs or + approved_by_author or + multiple_dst_branches): raise exceptions.RequestIntegrationBranches( active_options=job.active_options, )