From 5a196530347f98e36c48f1a84efbc7fe6059e563 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2017 14:49:34 +0000 Subject: Require not only a flag from a certain API token but also with a certain title --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 3855410..81085a0 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -1693,7 +1693,8 @@ class PullRequest(BASE): if mandatory_flags: flag_ok = False for flag in self.flags: - if flag.token_id in mandatory_flags: + if flag.token_id in mandatory_flags \ + and flag.username == mandatory_flags[flag.token_id]: flag_ok = flag.percent == 100 else: flag_ok = True diff --git a/tests/test_pagure_flask_api_fork.py b/tests/test_pagure_flask_api_fork.py index af8378e..1e6d035 100644 --- a/tests/test_pagure_flask_api_fork.py +++ b/tests/test_pagure_flask_api_fork.py @@ -1229,7 +1229,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch('pagure.lib.notify.send_email') @patch('pagure.lib.git.merge_pull_request') - @patch.dict('pagure.APP.config', {'MANDATORY_FLAGS': 'foobar'}) + @patch.dict( + 'pagure.APP.config', {'MANDATORY_FLAGS': {'foobar': 'koji'}}) def test_api_pull_request_merge_no_flag(self, mpr, send_email): """ Test the api_pull_request_merge method of the flask api when the PR is missing one of the mandatory flag. @@ -1305,7 +1306,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch('pagure.lib.notify.send_email') @patch('pagure.lib.git.merge_pull_request') - @patch.dict('pagure.APP.config', {'MANDATORY_FLAGS': 'foobar'}) + @patch.dict( + 'pagure.APP.config', {'MANDATORY_FLAGS': {'foobar': 'koji'}}) def test_api_pull_request_merge_w_invalid_flag(self, mpr, send_email): """ Test the api_pull_request_merge method of the flask api when the PR is missing one of the mandatory flag. @@ -1368,7 +1370,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch('pagure.lib.notify.send_email') @patch('pagure.lib.git.merge_pull_request') - @patch.dict('pagure.APP.config', {'MANDATORY_FLAGS': 'foobar'}) + @patch.dict( + 'pagure.APP.config', {'MANDATORY_FLAGS': {'foobar': 'koji'}}) def test_api_pull_request_merge_w_flag(self, mpr, send_email): """ Test the api_pull_request_merge method of the flask api when the PR is missing one of the mandatory flag. @@ -1428,7 +1431,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch('pagure.lib.notify.send_email') @patch('pagure.lib.git.merge_pull_request') - @patch.dict('pagure.APP.config', {'MANDATORY_FLAGS': 'foobar'}) + @patch.dict( + 'pagure.APP.config', {'MANDATORY_FLAGS': {'foobar': 'koji'}}) def test_api_pull_request_merge_w_two_flags(self, mpr, send_email): """ Test the api_pull_request_merge method of the flask api when the PR is missing one of the mandatory flag.