diff --git a/api/internal/tests/views/test_compare_viewset.py b/api/internal/tests/views/test_compare_viewset.py index cc0b004a70..c5eba93847 100644 --- a/api/internal/tests/views/test_compare_viewset.py +++ b/api/internal/tests/views/test_compare_viewset.py @@ -466,46 +466,3 @@ def test_pull_request_pseudo_comparison_can_update_base_report( assert response.status_code == status.HTTP_200_OK assert response.data["files"] == self.expected_files - - @patch("redis.Redis.get", lambda self, key: None) - @patch("redis.Redis.set", lambda self, key, val, ex: None) - @patch( - "services.comparison.PullRequestComparison.pseudo_diff_adjusts_tracked_lines", - new_callable=PropertyMock, - ) - @patch( - "services.comparison.PullRequestComparison.allow_coverage_offsets", - new_callable=PropertyMock, - ) - @patch( - "services.comparison.PullRequestComparison.update_base_report_with_pseudo_diff" - ) - def test_pull_request_pseudo_comparison_returns_error_if_coverage_offsets_not_allowed( - self, - update_base_report_mock, - allow_coverage_offsets_mock, - pseudo_diff_adjusts_tracked_lines_mock, - adapter_mock, - base_report_mock, - head_report_mock, - ): - adapter_mock.return_value = self.mocked_compare_adapter - base_report_mock.return_value = self.base_report - head_report_mock.return_value = self.head_report - - pseudo_diff_adjusts_tracked_lines_mock.return_value = True - allow_coverage_offsets_mock.return_value = False - - response = self._get_comparison( - query_params={ - "pullid": PullFactory( - base=self.base.commitid, - head=self.head.commitid, - compared_to=self.base.commitid, - pullid=2, - repository=self.repo, - ).pullid - } - ) - - assert response.status_code == status.HTTP_400_BAD_REQUEST diff --git a/api/public/v2/tests/test_api_compare_viewset.py b/api/public/v2/tests/test_api_compare_viewset.py index fc14ef1f0c..25c22664f7 100644 --- a/api/public/v2/tests/test_api_compare_viewset.py +++ b/api/public/v2/tests/test_api_compare_viewset.py @@ -667,49 +667,6 @@ def test_pull_request_pseudo_comparison_can_update_base_report( assert response.status_code == status.HTTP_200_OK assert response.data["files"] == self.expected_files - @patch("redis.Redis.get", lambda self, key: None) - @patch("redis.Redis.set", lambda self, key, val, ex: None) - @patch( - "services.comparison.PullRequestComparison.pseudo_diff_adjusts_tracked_lines", - new_callable=PropertyMock, - ) - @patch( - "services.comparison.PullRequestComparison.allow_coverage_offsets", - new_callable=PropertyMock, - ) - @patch( - "services.comparison.PullRequestComparison.update_base_report_with_pseudo_diff" - ) - def test_pull_request_pseudo_comparison_returns_error_if_coverage_offsets_not_allowed( - self, - update_base_report_mock, - allow_coverage_offsets_mock, - pseudo_diff_adjusts_tracked_lines_mock, - adapter_mock, - base_report_mock, - head_report_mock, - ): - adapter_mock.return_value = self.mocked_compare_adapter - base_report_mock.return_value = self.base_report - head_report_mock.return_value = self.head_report - - pseudo_diff_adjusts_tracked_lines_mock.return_value = True - allow_coverage_offsets_mock.return_value = False - - response = self._get_comparison( - query_params={ - "pullid": PullFactory( - base=self.base.commitid, - head=self.head.commitid, - compared_to=self.base.commitid, - pullid=2, - repository=self.repo, - ).pullid - } - ) - - assert response.status_code == status.HTTP_400_BAD_REQUEST - def test_flags_comparison(self, adapter_mock, base_report_mock, head_report_mock): adapter_mock.return_value = self.mocked_compare_adapter base_report_mock.return_value = self.base_report diff --git a/api/shared/compare/mixins.py b/api/shared/compare/mixins.py index bc6b4ac228..a8e288fc2c 100644 --- a/api/shared/compare/mixins.py +++ b/api/shared/compare/mixins.py @@ -87,23 +87,10 @@ def retrieve(self, request, *args, **kwargs): comparison = self.get_object() # Some checks here for pseudo-comparisons. Basically, when pseudo-comparing, - # we sometimes might need to tweak the base report if the user allows us to - # in their yaml, or raise an error if not. + # we sometimes might need to tweak the base report if isinstance(comparison, PullRequestComparison): - if ( - comparison.pseudo_diff_adjusts_tracked_lines - and comparison.allow_coverage_offsets - ): + if comparison.pseudo_diff_adjusts_tracked_lines: comparison.update_base_report_with_pseudo_diff() - elif comparison.pseudo_diff_adjusts_tracked_lines: - return Response( - data={ - "detail": "Changes found in between %.7s...%.7s (pseudo...base) " - "which prevent comparing this pull request." - % (comparison.pull.compared_to, comparison.pull.base) - }, - status=400, - ) serializer = self.get_serializer(comparison) try: