Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion crowdin_api/api_resources/branches/tests/test_branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from crowdin_api.api_resources.branches.enums import ListBranchesOrderBy, EditBranchPatchPath
from crowdin_api.api_resources.branches.resource import BranchesResource
from crowdin_api.api_resources.branches.types import CloneBranchRequest, AddBranchRequest, EditBranchPatch
from crowdin_api.api_resources.branches.types import CloneBranchRequest, AddBranchRequest, EditBranchPatch, \
MergeBranchRequest
from crowdin_api.api_resources.enums import PatchOperation
from crowdin_api.requester import APIRequester
from crowdin_api.sorting import SortingRule, Sorting, SortingOrder
Expand Down Expand Up @@ -205,3 +206,38 @@ def test_edit_branch(self, m_request, in_body, request_body, base_absolut_url):
path=f"projects/{project_id}/branches/{branch_id}",
request_data=request_body
)

@pytest.mark.parametrize(
"in_data, request_data",
(
(
MergeBranchRequest(
sourceBranchId=1,
deleteAfterMerge=True,
dryRun=True,
acceptSourceChanges=True
),
{
"sourceBranchId": 1,
"deleteAfterMerge": True,
"dryRun": True,
"acceptSourceChanges": True
}
),
),
)
@mock.patch("crowdin_api.requester.APIRequester.request")
def test_merge_branches(self, m_request, in_data, request_data, base_absolut_url):
m_request.return_value = "response"

project_id = 1
branch_id = 2

resource = self.get_resource(base_absolut_url)
assert resource.merge_branch(project_id, branch_id, in_data) == "response"

m_request.assert_called_once_with(
method="post",
path=f"projects/{project_id}/branches/{branch_id}/merges",
request_data=request_data,
)
1 change: 1 addition & 0 deletions crowdin_api/api_resources/branches/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ class MergeBranchRequest(TypedDict):
deleteAfterMerge: Optional[bool]
sourceBranchId: int
dryRun: Optional[bool]
acceptSourceChanges: Optional[bool]