Skip to content
Snippets Groups Projects
Verified Commit b5c62f46 authored by Yoann Schneider's avatar Yoann Schneider :tennis:
Browse files

match post data sent

parent 38f214c4
No related branches found
No related tags found
1 merge request!112Bump Python requirement python-gitlab to 3.9.0
Pipeline #79450 passed
...@@ -4,6 +4,7 @@ from pathlib import Path ...@@ -4,6 +4,7 @@ from pathlib import Path
import pytest import pytest
from gitlab import GitlabCreateError, GitlabError from gitlab import GitlabCreateError, GitlabError
from requests import ConnectionError from requests import ConnectionError
from responses import matchers
from arkindex_worker.git import GitlabHelper from arkindex_worker.git import GitlabHelper
...@@ -222,6 +223,7 @@ def test_merge_request(fake_responses, fake_gitlab_helper_factory, mocker): ...@@ -222,6 +223,7 @@ def test_merge_request(fake_responses, fake_gitlab_helper_factory, mocker):
"state": "merged", "state": "merged",
# several fields omitted # several fields omitted
}, },
match=[matchers.json_params_matcher({"should_remove_source_branch": True})],
) )
# the fake_responses are defined in the same order as they are expected to be called # the fake_responses are defined in the same order as they are expected to be called
...@@ -233,7 +235,6 @@ def test_merge_request(fake_responses, fake_gitlab_helper_factory, mocker): ...@@ -233,7 +235,6 @@ def test_merge_request(fake_responses, fake_gitlab_helper_factory, mocker):
gitlab_helper._wait_for_rebase_to_finish.return_value = True gitlab_helper._wait_for_rebase_to_finish.return_value = True
success = gitlab_helper.merge(SOURCE_BRANCH, MR_TITLE) success = gitlab_helper.merge(SOURCE_BRANCH, MR_TITLE)
assert success assert success
assert len(fake_responses.calls) == 4 assert len(fake_responses.calls) == 4
assert [c.request.method for c in fake_responses.calls] == expected_http_methods assert [c.request.method for c in fake_responses.calls] == expected_http_methods
...@@ -258,6 +259,7 @@ def test_merge_request_fail(fake_responses, fake_gitlab_helper_factory, mocker): ...@@ -258,6 +259,7 @@ def test_merge_request_fail(fake_responses, fake_gitlab_helper_factory, mocker):
f"https://gitlab.com/api/v4/projects/{PROJECT_ID}/merge_requests/{MERGE_REQUEST_ID}/merge", f"https://gitlab.com/api/v4/projects/{PROJECT_ID}/merge_requests/{MERGE_REQUEST_ID}/merge",
json={"error": "Method not allowed"}, json={"error": "Method not allowed"},
status=405, status=405,
match=[matchers.json_params_matcher({"should_remove_source_branch": True})],
) )
# the fake_responses are defined in the same order as they are expected to be called # the fake_responses are defined in the same order as they are expected to be called
...@@ -346,6 +348,7 @@ def test_merge_request__success_after_errors( ...@@ -346,6 +348,7 @@ def test_merge_request__success_after_errors(
"state": "merged", "state": "merged",
# several fields omitted # several fields omitted
}, },
match=[matchers.json_params_matcher({"should_remove_source_branch": True})],
) )
# the fake_responses are defined in the same order as they are expected to be called # the fake_responses are defined in the same order as they are expected to be called
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment