From fa06cf69e13d4b1767055d939046c00c7543a24f Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Fri, 25 Oct 2019 10:09:12 +0200 Subject: [PATCH] Pagure: Fix handling of threshold_reached: None Threshold_reached will be None (in the API) if no minimal score to merge PR is configured. So the value needs to be handled as True because the threshold is by default reached in that case. Change-Id: I103c9f601e5362f451647fb3597fa790df481dd6 --- tests/unit/test_pagure_driver.py | 3 ++- zuul/driver/pagure/pagureconnection.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_pagure_driver.py b/tests/unit/test_pagure_driver.py index deb6ea3ccb..2f3369243c 100644 --- a/tests/unit/test_pagure_driver.py +++ b/tests/unit/test_pagure_driver.py @@ -460,7 +460,8 @@ class TestPagureDriver(ZuulTestCase): self.assertEqual(0, len(self.history)) # Set the score threshold as reached - A.threshold_reached = True + # Here we use None that means no specific score is required + A.threshold_reached = None self.fake_pagure.emitEvent(A.getPullRequestOpenedEvent()) self.waitUntilSettled() # connection.canMerge is not validated diff --git a/zuul/driver/pagure/pagureconnection.py b/zuul/driver/pagure/pagureconnection.py index d844a00b50..23e6e9ee15 100644 --- a/zuul/driver/pagure/pagureconnection.py +++ b/zuul/driver/pagure/pagureconnection.py @@ -785,9 +785,13 @@ class PagureConnection(BaseConnection): if self._hasRequiredStatusChecks(change): ci_flag = True + # By default project get -1 in "Minimum score to merge pull-request" + # But this makes the API to return None for threshold_reached. We need + # to handle this case as threshold_reached: True because it means + # no minimal score configured. threshold = pr.get('threshold_reached') if threshold is None: - self.log.debug("No threshold_reached attribute found") + threshold = True log.debug( 'PR %s#%s mergeability details mergeable: %s '