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

Commit 076573a

Browse files
committed
try fixing tests
1 parent 858a481 commit 076573a

File tree

16 files changed

+69
-65
lines changed

16 files changed

+69
-65
lines changed

api/internal/tests/test_charts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def test_apply_simple_filters_branch_filtering(self):
318318
for commit in queryset:
319319
assert (
320320
commit.repository.name == self.repo1_org1.name
321-
and commit.branch == "master"
321+
and commit.branch == "main"
322322
) or (
323323
commit.repository.name == branch_test.name and commit.branch == "main"
324324
)

api/internal/tests/unit/views/test_compare_flags_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
@patch("services.comparison.Comparison.git_comparison", new_callable=PropertyMock)
18-
@patch("services.archive.ArchiveService.read_chunks")
18+
@patch("shared.api_archive.archive.ArchiveService.read_chunks")
1919
@patch("shared.reports.filtered.FilteredReport.apply_diff")
2020
@patch(
2121
"api.shared.repo.repository_accessors.RepoAccessors.get_repo_permissions",

api/internal/tests/unit/views/test_compare_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def build_commits(client):
4646
return repo, commit_base, commit_head
4747

4848

49-
@patch("services.archive.ArchiveService.read_chunks", lambda obj, sha: "")
49+
@patch("shared.api_archive.archive.ArchiveService.read_chunks", lambda obj, sha: "")
5050
@patch(
5151
"api.shared.repo.repository_accessors.RepoAccessors.get_repo_permissions",
5252
lambda self, repo, user: (True, True),

api/internal/tests/views/test_repo_view.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def test_retrieve_with_no_commits_doesnt_crash(self, mocked_get_permissions):
726726
response = self._retrieve()
727727
assert response.status_code == 200
728728

729-
@patch("services.archive.ArchiveService.read_chunks", lambda obj, _: "")
729+
@patch("shared.api_archive.archive.ArchiveService.read_chunks", lambda obj, _: "")
730730
def test_retrieve_returns_latest_commit_data(self, mocked_get_permissions):
731731
self.maxDiff = None
732732
mocked_get_permissions.return_value = True, True
@@ -803,7 +803,7 @@ def test_retrieve_returns_latest_commit_data(self, mocked_get_permissions):
803803
],
804804
)
805805

806-
@patch("services.archive.ArchiveService.read_chunks", lambda obj, _: "")
806+
@patch("shared.api_archive.archive.ArchiveService.read_chunks", lambda obj, _: "")
807807
def test_retrieve_returns_latest_commit_of_default_branch_if_branch_not_specified(
808808
self, mocked_get_permissions
809809
):
@@ -817,7 +817,7 @@ def test_retrieve_returns_latest_commit_of_default_branch_if_branch_not_specifie
817817
assert response.data["latest_commit"]["commitid"] == commit.commitid
818818
assert response.data["latest_commit"]["commitid"] != more_recent_commit.commitid
819819

820-
@patch("services.archive.ArchiveService.read_chunks", lambda obj, _: "")
820+
@patch("shared.api_archive.archive.ArchiveService.read_chunks", lambda obj, _: "")
821821
def test_retrieve_accepts_branch_query_param_to_specify_latest_commit(
822822
self, mocked_get_permissions
823823
):
@@ -831,7 +831,7 @@ def test_retrieve_accepts_branch_query_param_to_specify_latest_commit(
831831
assert response.data["latest_commit"]["commitid"] == commit.commitid
832832
assert response.data["latest_commit"]["commitid"] != more_recent_commit.commitid
833833

834-
@patch("services.archive.ArchiveService.read_chunks", lambda obj, _: "")
834+
@patch("shared.api_archive.archive.ArchiveService.read_chunks", lambda obj, _: "")
835835
def test_latest_commit_is_none_if_dne(self, mocked_get_permissions):
836836
mocked_get_permissions.return_value = True, True
837837

api/public/v2/tests/test_api_compare_viewset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ def setUp(self):
875875
self.client.force_login_owner(self.current_owner)
876876

877877
@patch("shared.reports.api_report_service.build_report_from_commit")
878-
@patch("services.archive.ArchiveService.read_file")
878+
@patch("shared.api_archive.archive.ArchiveService.read_file")
879879
@patch("services.repo_providers.RepoProviderService.get_adapter")
880880
def test_impacted_files_200_found(
881881
self, adapter_mock, read_file, build_report_from_commit
@@ -911,7 +911,7 @@ def test_impacted_files_200_found(
911911
assert data["state"] == "processed"
912912

913913
@patch("shared.reports.api_report_service.build_report_from_commit")
914-
@patch("services.archive.ArchiveService.read_file")
914+
@patch("shared.api_archive.archive.ArchiveService.read_file")
915915
@patch("services.repo_providers.RepoProviderService.get_adapter")
916916
@patch("services.task.TaskService.compute_comparison")
917917
@patch("api.shared.compare.serializers.ComparisonSerializer.get_files")
@@ -954,7 +954,7 @@ def test_impacted_files_200_not_found(
954954

955955
@patch("services.comparison.Comparison.validate")
956956
@patch("services.comparison.PullRequestComparison.get_file_comparison")
957-
@patch("services.archive.ArchiveService.read_file")
957+
@patch("shared.api_archive.archive.ArchiveService.read_file")
958958
@patch("services.repo_providers.RepoProviderService.get_adapter")
959959
def test_impacted_file_segment_found(
960960
self, adapter_mock, read_file, mock_get_file_comparison, mock_compare_validate
@@ -992,7 +992,7 @@ def test_impacted_file_segment_found(
992992
@patch("services.task.TaskService.compute_comparison")
993993
@patch("services.comparison.Comparison.validate")
994994
@patch("services.comparison.PullRequestComparison.get_file_comparison")
995-
@patch("services.archive.ArchiveService.read_file")
995+
@patch("shared.api_archive.archive.ArchiveService.read_file")
996996
@patch("services.repo_providers.RepoProviderService.get_adapter")
997997
def test_impacted_file_segment_not_found(
998998
self,

api/public/v2/tests/test_api_repo_viewset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_list(self):
5757
"name": self.org.name,
5858
},
5959
"language": self.repo.language,
60-
"branch": "master",
60+
"branch": "main",
6161
"active": False,
6262
"activated": False,
6363
"totals": {
@@ -110,7 +110,7 @@ def test_retrieve(self, get_repo_permissions):
110110
"name": self.org.name,
111111
},
112112
"language": self.repo.language,
113-
"branch": "master",
113+
"branch": "main",
114114
"active": False,
115115
"activated": False,
116116
"totals": {

compare/commands/compare/interactors/tests/test_fetch_impacted_files.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def execute(self, owner, *args):
362362
service = owner.service if owner else "github"
363363
return FetchImpactedFiles(owner, service).execute(*args)
364364

365-
@patch("services.archive.ArchiveService.read_file")
365+
@patch("shared.api_archive.archive.ArchiveService.read_file")
366366
def test_impacted_file_sort_function(self, read_file):
367367
read_file.return_value = mock_data_from_archive
368368
parameter = ImpactedFileParameter.CHANGE_COVERAGE
@@ -372,7 +372,7 @@ def test_impacted_file_sort_function(self, read_file):
372372
sorted_files = self.execute(None, self.comparison_report, comparison, filters)
373373
assert [file.head_name for file in sorted_files] == ["fileA", "fileB"]
374374

375-
@patch("services.archive.ArchiveService.read_file")
375+
@patch("shared.api_archive.archive.ArchiveService.read_file")
376376
def test_impacted_file_sort_function_no_misses(self, read_file):
377377
read_file.return_value = mock_data_without_misses
378378
parameter = ImpactedFileParameter.MISSES_COUNT
@@ -382,7 +382,7 @@ def test_impacted_file_sort_function_no_misses(self, read_file):
382382
sorted_files = self.execute(None, self.comparison_report, comparison, filters)
383383
assert [file.head_name for file in sorted_files] == ["fileA", "fileB"]
384384

385-
@patch("services.archive.ArchiveService.read_file")
385+
@patch("shared.api_archive.archive.ArchiveService.read_file")
386386
def test_impacted_file_sort_function_error(self, read_file):
387387
read_file.return_value = mock_data_from_archive
388388
parameter = "something else"
@@ -396,7 +396,7 @@ def test_impacted_file_sort_function_error(self, read_file):
396396
"invalid impacted file parameter: something else", str(ctx.exception)
397397
)
398398

399-
@patch("services.archive.ArchiveService.read_file")
399+
@patch("shared.api_archive.archive.ArchiveService.read_file")
400400
def test_impacted_files_filtered_by_change_coverage_ascending(self, read_file):
401401
read_file.return_value = mock_data_from_archive
402402
filters = {
@@ -409,7 +409,7 @@ def test_impacted_files_filtered_by_change_coverage_ascending(self, read_file):
409409
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
410410
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
411411

412-
@patch("services.archive.ArchiveService.read_file")
412+
@patch("shared.api_archive.archive.ArchiveService.read_file")
413413
def test_impacted_files_filtered_by_change_coverage_descending(self, read_file):
414414
read_file.return_value = mock_data_from_archive
415415
filters = {
@@ -422,7 +422,7 @@ def test_impacted_files_filtered_by_change_coverage_descending(self, read_file):
422422
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
423423
assert [file.head_name for file in impacted_files] == ["fileB", "fileA"]
424424

425-
@patch("services.archive.ArchiveService.read_file")
425+
@patch("shared.api_archive.archive.ArchiveService.read_file")
426426
def test_impacted_files_filtered_by_head_coverage_ascending(self, read_file):
427427
read_file.return_value = mock_data_from_archive
428428
filters = {
@@ -435,7 +435,7 @@ def test_impacted_files_filtered_by_head_coverage_ascending(self, read_file):
435435
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
436436
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
437437

438-
@patch("services.archive.ArchiveService.read_file")
438+
@patch("shared.api_archive.archive.ArchiveService.read_file")
439439
def test_impacted_files_filtered_by_patch_coverage_ascending(self, read_file):
440440
read_file.return_value = mock_data_from_archive
441441
filters = {
@@ -448,7 +448,7 @@ def test_impacted_files_filtered_by_patch_coverage_ascending(self, read_file):
448448
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
449449
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
450450

451-
@patch("services.archive.ArchiveService.read_file")
451+
@patch("shared.api_archive.archive.ArchiveService.read_file")
452452
def test_impacted_files_filtered_by_patch_coverage_descending(self, read_file):
453453
read_file.return_value = mock_data_from_archive
454454
filters = {
@@ -461,7 +461,7 @@ def test_impacted_files_filtered_by_patch_coverage_descending(self, read_file):
461461
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
462462
assert [file.head_name for file in impacted_files] == ["fileB", "fileA"]
463463

464-
@patch("services.archive.ArchiveService.read_file")
464+
@patch("shared.api_archive.archive.ArchiveService.read_file")
465465
def test_impacted_files_filtered_by_head_coverage_descending(self, read_file):
466466
read_file.return_value = mock_data_from_archive
467467
filters = {
@@ -474,7 +474,7 @@ def test_impacted_files_filtered_by_head_coverage_descending(self, read_file):
474474
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
475475
assert [file.head_name for file in impacted_files] == ["fileB", "fileA"]
476476

477-
@patch("services.archive.ArchiveService.read_file")
477+
@patch("shared.api_archive.archive.ArchiveService.read_file")
478478
def test_impacted_files_filtered_by_head_name_ascending(self, read_file):
479479
read_file.return_value = mock_data_from_archive
480480
filters = {
@@ -487,7 +487,7 @@ def test_impacted_files_filtered_by_head_name_ascending(self, read_file):
487487
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
488488
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
489489

490-
@patch("services.archive.ArchiveService.read_file")
490+
@patch("shared.api_archive.archive.ArchiveService.read_file")
491491
def test_impacted_files_filtered_by_head_name_descending(self, read_file):
492492
read_file.return_value = mock_data_from_archive
493493
filters = {
@@ -500,7 +500,7 @@ def test_impacted_files_filtered_by_head_name_descending(self, read_file):
500500
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
501501
assert [file.head_name for file in impacted_files] == ["fileB", "fileA"]
502502

503-
@patch("services.archive.ArchiveService.read_file")
503+
@patch("shared.api_archive.archive.ArchiveService.read_file")
504504
def test_impacted_files_filtered_by_misses_count_ascending(self, read_file):
505505
read_file.return_value = mock_data_from_archive
506506
filters = {
@@ -513,7 +513,7 @@ def test_impacted_files_filtered_by_misses_count_ascending(self, read_file):
513513
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
514514
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
515515

516-
@patch("services.archive.ArchiveService.read_file")
516+
@patch("shared.api_archive.archive.ArchiveService.read_file")
517517
def test_impacted_files_filtered_by_misses_count_descending(self, read_file):
518518
read_file.return_value = mock_data_from_archive
519519
filters = {
@@ -526,15 +526,15 @@ def test_impacted_files_filtered_by_misses_count_descending(self, read_file):
526526
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
527527
assert [file.head_name for file in impacted_files] == ["fileB", "fileA"]
528528

529-
@patch("services.archive.ArchiveService.read_file")
529+
@patch("shared.api_archive.archive.ArchiveService.read_file")
530530
def test_impacted_files_without_filters(self, read_file):
531531
read_file.return_value = mock_data_from_archive
532532
filters = {}
533533
comparison = None
534534
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
535535
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
536536

537-
@patch("services.archive.ArchiveService.read_file")
537+
@patch("shared.api_archive.archive.ArchiveService.read_file")
538538
def test_impacted_files_filtered_by_unintended_changes(self, read_file):
539539
read_file.return_value = mock_data_from_archive
540540
filters = {
@@ -548,7 +548,7 @@ def test_impacted_files_filtered_by_unintended_changes(self, read_file):
548548
impacted_files = self.execute(None, self.comparison_report, comparison, filters)
549549
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
550550

551-
@patch("services.archive.ArchiveService.read_file")
551+
@patch("shared.api_archive.archive.ArchiveService.read_file")
552552
def test_impacted_files_filtered_by_unintended_changes_set_to_false(
553553
self, read_file
554554
):
@@ -565,7 +565,7 @@ def test_impacted_files_filtered_by_unintended_changes_set_to_false(
565565
assert [file.head_name for file in impacted_files] == ["fileA", "fileB"]
566566

567567
@patch("services.comparison.Comparison.head_report", new_callable=PropertyMock)
568-
@patch("services.archive.ArchiveService.read_file")
568+
@patch("shared.api_archive.archive.ArchiveService.read_file")
569569
def test_impacted_files_filtered_by_flags_and_commit_comparison_for_pull(
570570
self, read_file, build_report_from_commit_mock
571571
):
@@ -606,7 +606,7 @@ def test_impacted_files_filtered_by_flags_and_commit_comparison_for_pull(
606606
assert impacted_files[0].head_name == "fileA"
607607

608608
@patch("services.comparison.Comparison.head_report", new_callable=PropertyMock)
609-
@patch("services.archive.ArchiveService.read_file")
609+
@patch("shared.api_archive.archive.ArchiveService.read_file")
610610
def test_impacted_files_filtered_by_flags_and_commit_comparison_for_parent_commit(
611611
self, read_file, build_report_from_commit_mock
612612
):
@@ -640,7 +640,7 @@ def test_impacted_files_filtered_by_flags_and_commit_comparison_for_parent_commi
640640

641641
@patch("services.components.commit_components")
642642
@patch("services.comparison.Comparison.head_report", new_callable=PropertyMock)
643-
@patch("services.archive.ArchiveService.read_file")
643+
@patch("shared.api_archive.archive.ArchiveService.read_file")
644644
def test_impacted_files_filtered_by_components_and_commit_comparison_for_parent_commit(
645645
self, read_file, build_report_from_commit_mock, commit_components_mock
646646
):
@@ -683,7 +683,7 @@ def test_impacted_files_filtered_by_components_and_commit_comparison_for_parent_
683683

684684
@patch("services.components.commit_components")
685685
@patch("services.comparison.Comparison.head_report", new_callable=PropertyMock)
686-
@patch("services.archive.ArchiveService.read_file")
686+
@patch("shared.api_archive.archive.ArchiveService.read_file")
687687
def test_impacted_files_filtered_by_components_using_flags(
688688
self, read_file, build_report_from_commit_mock, commit_components_mock
689689
):
@@ -732,7 +732,7 @@ def test_impacted_files_filtered_by_components_using_flags(
732732

733733
@patch("services.components.commit_components")
734734
@patch("services.comparison.Comparison.head_report", new_callable=PropertyMock)
735-
@patch("services.archive.ArchiveService.read_file")
735+
@patch("shared.api_archive.archive.ArchiveService.read_file")
736736
def test_impacted_files_filtered_by_components_and_flags_commit_comparison_for_parent_commit(
737737
self, read_file, build_report_from_commit_mock, commit_components_mock
738738
):

core/commands/branch/interactors/tests/test_fetch_branches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FetchRepoBranchesInteractorTest(TransactionTestCase):
1515
def setUp(self):
1616
self.org = OwnerFactory(username="codecov")
1717
self.repo = RepositoryFactory(
18-
author=self.org, name="gazebo", private=False, branch="master"
18+
author=self.org, name="gazebo", private=False, branch="main"
1919
)
2020
self.head = CommitFactory(repository=self.repo)
2121
self.commit = CommitFactory(repository=self.repo)
@@ -32,7 +32,7 @@ def test_fetch_branches(self):
3232
repository = self.repo
3333
filters = {}
3434
branches = async_to_sync(self.execute)(None, repository, filters)
35-
assert any(branch.name == "master" for branch in branches)
35+
assert any(branch.name == "main" for branch in branches)
3636
assert any(branch.name == "test1" for branch in branches)
3737
assert any(branch.name == "test2" for branch in branches)
3838
assert len(branches) == 3

graphql_api/tests/test_branch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_fetch_branches(self):
219219
assert branches == [
220220
{"node": {"name": "test2"}},
221221
{"node": {"name": "test1"}},
222-
{"node": {"name": "master"}},
222+
{"node": {"name": "main"}},
223223
]
224224

225225
def test_fetch_branches_with_filters(self):

graphql_api/tests/test_components_legacy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
from django.conf import settings
55
from django.test import TransactionTestCase, override_settings
66
from django.utils import timezone
7+
from shared.django_apps.core.tests.factories import (
8+
CommitFactory,
9+
PullFactory,
10+
RepositoryFactory,
11+
)
712
from shared.reports.resources import Report, ReportFile, ReportLine
813
from shared.utils.sessions import Session
914

1015
from codecov_auth.tests.factories import OwnerFactory
1116
from compare.models import CommitComparison
1217
from compare.tests.factories import CommitComparisonFactory, ComponentComparisonFactory
13-
from core.tests.factories import CommitFactory, PullFactory, RepositoryFactory
1418
from services.comparison import MissingComparisonReport
1519
from services.components import Component
1620
from timeseries.models import MeasurementName

0 commit comments

Comments
 (0)