From 5d0d0490d26bc51d0033938e767f373b64450b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kone=C4=8Dn=C3=BD?= Date: Thu, 24 Mar 2022 17:57:29 +0100 Subject: [PATCH] Fix unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Konečný --- tests/plugins/test_scm_request_processor.py | 5 +++-- tests/utils/test_pagure.py | 4 ++-- toddlers/plugins/scm_request_processor.py | 4 +--- toddlers/utils/pagure.py | 6 ++++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/plugins/test_scm_request_processor.py b/tests/plugins/test_scm_request_processor.py index e2fd125..4aa8d11 100644 --- a/tests/plugins/test_scm_request_processor.py +++ b/tests/plugins/test_scm_request_processor.py @@ -86,7 +86,7 @@ class TestProcess: msg = IssueNewV1() msg.body = { "project": {"fullname": scm_request_processor.PROJECT_NAMESPACE}, - "issue": {"id": 100, "close_status": "Closed"}, + "issue": {"id": 100, "status": "Closed"}, } with patch( @@ -110,7 +110,7 @@ class TestProcess: initial processing. """ msg = IssueNewV1() - issue = {"id": 100, "close_status": "Open"} + issue = {"id": 100, "status": "Open"} msg.body = { "project": {"fullname": scm_request_processor.PROJECT_NAMESPACE}, "issue": issue, @@ -2792,4 +2792,5 @@ class TestMain: ) message = IssueNewV1() message.body["issue"] = mock_issue + message.body["project"] = {"fullname": scm_request_processor.PROJECT_NAMESPACE} mock_process.assert_called_with(config={}, message=message) diff --git a/tests/utils/test_pagure.py b/tests/utils/test_pagure.py index 1f77183..806d139 100644 --- a/tests/utils/test_pagure.py +++ b/tests/utils/test_pagure.py @@ -244,7 +244,7 @@ class TestPagureAddCommentToIssue: self.pagure.add_comment_to_issue(issue_id, namespace, message) self.pagure._requests_session.post.assert_called_with( - "https://pagure.io/test/issue/100/comment", + "https://pagure.io/api/0/test/issue/100/comment", data={"comment": message}, headers=self.pagure.get_auth_header(), ) @@ -268,7 +268,7 @@ class TestPagureAddCommentToIssue: self.pagure.add_comment_to_issue(issue_id, namespace, message) self.pagure._requests_session.post.assert_called_with( - "https://pagure.io/test/issue/100/comment", + "https://pagure.io/api/0/test/issue/100/comment", data={"comment": message}, headers=self.pagure.get_auth_header(), ) diff --git a/toddlers/plugins/scm_request_processor.py b/toddlers/plugins/scm_request_processor.py index 618e4f3..c82c2cd 100644 --- a/toddlers/plugins/scm_request_processor.py +++ b/toddlers/plugins/scm_request_processor.py @@ -1058,9 +1058,7 @@ def main(args): # Convert issue to message message = IssueNewV1() message.body["issue"] = issue - message.body["project"] = { - "fullname": PROJECT_NAMESPACE - } + message.body["project"] = {"fullname": PROJECT_NAMESPACE} _log.debug("Message prepared: {}".format(message.body)) SCMRequestProcessor().process( diff --git a/toddlers/utils/pagure.py b/toddlers/utils/pagure.py index b1f932b..1aecbd5 100644 --- a/toddlers/utils/pagure.py +++ b/toddlers/utils/pagure.py @@ -176,8 +176,10 @@ class Pagure: Raises: toddlers.utils.exceptions.PagureError: When the issue couldn't be commented on. """ - issue_url = "{0}/api/0/{1}/issue/{2}".format(self._pagure_url, namespace, issue_id) - api_url = "{0}/comment".format(issue_url) + issue_url = "{0}/{1}/issue/{2}".format(self._pagure_url, namespace, issue_id) + api_url = "{0}/api/0/{1}/issue/{2}/comment".format( + self._pagure_url, namespace, issue_id + ) comment_payload = {"comment": comment} headers = self.get_auth_header()