From 7f0848002c75010e132ebb84f2be5f6d84221afa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Oct 2025 09:03:01 +0000 Subject: [PATCH 1/3] Add missing unit tests for GitMergeHandler Co-authored-by: balajirajput96 <124477404+balajirajput96@users.noreply.github.com> --- jupyterlab_git/tests/test_handlers.py | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/jupyterlab_git/tests/test_handlers.py b/jupyterlab_git/tests/test_handlers.py index 0c8c9ca4f..402514ab2 100644 --- a/jupyterlab_git/tests/test_handlers.py +++ b/jupyterlab_git/tests/test_handlers.py @@ -1089,3 +1089,52 @@ async def test_content_getcontent_deleted_file(mock_execute, jp_fetch, jp_root_d assert response.code == 200 payload = json.loads(response.body) assert payload["content"] == "" + + +@patch("jupyterlab_git.handlers.GitMergeHandler.git", spec=Git) +async def test_merge_handler_success(mock_git, jp_fetch, jp_root_dir): + # Given + local_path = jp_root_dir / "test_path" + branch_to_merge = "feature-branch" + merge_result = { + "code": 0, + "message": "Merge made by the 'ort' strategy." + } + mock_git.merge.return_value = maybe_future(merge_result) + + # When + body = {"branch": branch_to_merge} + response = await jp_fetch( + NAMESPACE, local_path.name, "merge", body=json.dumps(body), method="POST" + ) + + # Then + mock_git.merge.assert_called_with(branch_to_merge, str(local_path)) + assert response.code == 200 + payload = json.loads(response.body) + assert payload == merge_result + + +@patch("jupyterlab_git.handlers.GitMergeHandler.git", spec=Git) +async def test_merge_handler_conflict(mock_git, jp_fetch, jp_root_dir): + # Given + local_path = jp_root_dir / "test_path" + branch_to_merge = "conflicting-branch" + merge_result = { + "code": 1, + "command": "git merge conflicting-branch", + "message": "Automatic merge failed; fix conflicts and then commit the result." + } + mock_git.merge.return_value = maybe_future(merge_result) + + # When + body = {"branch": branch_to_merge} + response = await jp_fetch( + NAMESPACE, local_path.name, "merge", body=json.dumps(body), method="POST" + ) + + # Then + mock_git.merge.assert_called_with(branch_to_merge, str(local_path)) + assert response.code == 500 + payload = json.loads(response.body) + assert payload == merge_result From b7adda546db5519e51512b4464c0d253924ac269 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Oct 2025 09:06:13 +0000 Subject: [PATCH 2/3] Format merge tests with black Co-authored-by: balajirajput96 <124477404+balajirajput96@users.noreply.github.com> --- jupyterlab_git/tests/test_handlers.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jupyterlab_git/tests/test_handlers.py b/jupyterlab_git/tests/test_handlers.py index 402514ab2..43757f47f 100644 --- a/jupyterlab_git/tests/test_handlers.py +++ b/jupyterlab_git/tests/test_handlers.py @@ -1096,10 +1096,7 @@ async def test_merge_handler_success(mock_git, jp_fetch, jp_root_dir): # Given local_path = jp_root_dir / "test_path" branch_to_merge = "feature-branch" - merge_result = { - "code": 0, - "message": "Merge made by the 'ort' strategy." - } + merge_result = {"code": 0, "message": "Merge made by the 'ort' strategy."} mock_git.merge.return_value = maybe_future(merge_result) # When @@ -1123,7 +1120,7 @@ async def test_merge_handler_conflict(mock_git, jp_fetch, jp_root_dir): merge_result = { "code": 1, "command": "git merge conflicting-branch", - "message": "Automatic merge failed; fix conflicts and then commit the result." + "message": "Automatic merge failed; fix conflicts and then commit the result.", } mock_git.merge.return_value = maybe_future(merge_result) From 75d55020a61ad642f85a53acf627b81000cb2494 Mon Sep 17 00:00:00 2001 From: Balaji_Rajput <124477404+balajirajput96@users.noreply.github.com> Date: Fri, 10 Oct 2025 10:00:13 +0530 Subject: [PATCH 3/3] Format merge tests with black Co-authored-by: balajirajput96 <124477404+balajirajput96@users.noreply.github.com> (#2) * Initial plan * Add missing unit tests for GitMergeHandler Co-authored-by: balajirajput96 <124477404+balajirajput96@users.noreply.github.com> * Format merge tests with black Co-authored-by: balajirajput96 <124477404+balajirajput96@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>