Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 0ac65ca

Browse files
Add test
1 parent 9ed8723 commit 0ac65ca

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

api/public/v2/tests/test_api_pull_viewset.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,34 @@ def test_retrieve_with_patch_coverage_no_branches(
385385
assert res.status_code == 200
386386
data = res.json()
387387
assert data["patch"] == self.no_patch_response
388+
389+
@patch("api.public.v2.pull.serializers.ComparisonReport")
390+
@patch("services.comparison.CommitComparison.objects.filter")
391+
def test_retrieve_with_patch_coverage_no_commit_comparison(
392+
self, mock_cc_filter, mock_comparison_report
393+
):
394+
mock_cc_instance = MagicMock(is_processed=False)
395+
mock_cc_filter.return_value.select_related.return_value.first.return_value = (
396+
mock_cc_instance
397+
)
398+
399+
mock_file = MagicMock()
400+
mock_file.patch_coverage.hits = 0
401+
mock_file.patch_coverage.misses = 0
402+
mock_file.patch_coverage.partials = 0
403+
mock_comparison_report.return_value.impacted_files = [mock_file]
404+
405+
res = self.client.get(
406+
reverse(
407+
"api-v2-pulls-detail",
408+
kwargs={
409+
"service": self.org.service,
410+
"owner_username": self.org.username,
411+
"repo_name": self.repo.name,
412+
"pullid": self.pulls[0].pullid,
413+
},
414+
)
415+
)
416+
assert res.status_code == 200
417+
data = res.json()
418+
assert data["patch"] == self.no_patch_response

0 commit comments

Comments
 (0)