Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
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
1 change: 0 additions & 1 deletion codecov/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"core",
"graphql_api",
"labelanalysis",
"profiling",
"reports",
"staticanalysis",
"timeseries",
Expand Down
1 change: 0 additions & 1 deletion codecov/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
path("webhooks/", include("webhook_handlers.urls")),
path("graphql/", include("graphql_api.urls")),
path("", include("codecov_auth.urls")),
path("profiling/", include("profiling.urls")),
path(f"{settings.DJANGO_ADMIN_URL}/", admin.site.urls),
path("staticanalysis/", include("staticanalysis.urls")),
path("labels/", include("labelanalysis.urls")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setUp(self):
self.user = OwnerFactory(organizations=[self.org.ownerid])
RepositoryTokenFactory(repository=self.active_repo, key="random")

def execute(self, owner, repo, token_type="profiling"):
def execute(self, owner, repo, token_type="upload"):
return GetRepositoryTokenInteractor(owner, "github").execute(
repository=repo, token_type=token_type
)
Expand All @@ -44,11 +44,6 @@ async def test_when_repo_has_no_token(self):
assert token is not None
assert len(token) == 40

async def test_get_profiling_token(self):
token = await self.execute(owner=self.user, repo=self.active_repo)
assert token is not None
assert token == "random"

async def test_get_static_analysis_token(self):
token = await self.execute(
owner=self.user, repo=self.active_repo, token_type="static_analysis"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def execute(self, owner, repo):
return RegenerateRepositoryTokenInteractor(owner, "github").execute(
repo_name=repo.name,
owner_username=self.org.username,
token_type="profiling",
token_type="upload",
)

async def test_when_validation_error_repo_not_active(self):
Expand All @@ -44,14 +44,3 @@ async def test_when_validation_error_repo_not_active(self):
async def test_when_validation_error_repo_not_viewable(self):
with pytest.raises(ValidationError):
await self.execute(owner=self.random_user, repo=self.active_repo)

async def test_regenerate_profiling_token_repo_has_no_token(self):
token = await self.execute(owner=self.user, repo=self.repo_with_no_token)
assert token is not None
assert len(token) == 40

async def test_regenerate_profiling_token(self):
token = await self.execute(owner=self.user, repo=self.active_repo)
assert token is not None
assert token != "random"
assert len(token) == 40
20 changes: 0 additions & 20 deletions graphql_api/tests/mutation/test_regenerate_repository_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,6 @@ def test_when_validation_error_repo_not_viewable(self):
== "ValidationError"
)

def test_when_authenticated_regenerate_profiling_token(self):
user = OwnerFactory(
organizations=[self.org.ownerid], permission=[self.repo.repoid]
)
RepositoryTokenFactory(repository=self.repo, key="random")
data = self.gql_request(
query,
owner=user,
variables={
"input": {
"owner": "codecov",
"repoName": "gazebo",
"tokenType": "PROFILING",
}
},
)
newToken = data["regenerateRepositoryToken"]["token"]
assert newToken != "random"
assert len(newToken) == 40

def test_when_authenticated_regenerate_staticanalysis_token(self):
user = OwnerFactory(
organizations=[self.org.ownerid], permission=[self.repo.repoid]
Expand Down
40 changes: 11 additions & 29 deletions graphql_api/tests/test_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from shared.reports.types import ReportTotals

from services.components import Component
from services.profiling import CriticalFile

from .helper import GraphQLTestHelper

Expand Down Expand Up @@ -347,11 +346,8 @@ def test_fetch_path_contents_with_no_report(self, report_mock):
}
}

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_path_contents_with_files(self, report_mock, critical_files):
def test_fetch_path_contents_with_files(self, report_mock):
variables = {
"org": self.org.username,
"repo": self.repo.name,
Expand All @@ -365,7 +361,6 @@ def test_fetch_path_contents_with_files(self, report_mock, critical_files):
},
}
report_mock.return_value = MockReport()
critical_files.return_value = [CriticalFile("fileA.py")]

data = self.gql_request(query_files, variables=variables)
assert data == {
Expand Down Expand Up @@ -406,7 +401,7 @@ def test_fetch_path_contents_with_files(self, report_mock, critical_files):
"partials": 0,
"lines": 10,
"percentCovered": 80.0,
"isCriticalFile": True,
"isCriticalFile": False,
},
],
}
Expand All @@ -416,12 +411,10 @@ def test_fetch_path_contents_with_files(self, report_mock, critical_files):
}
}

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_path_contents_with_files_and_path_prefix(
self, report_mock, critical_files
self,
report_mock,
):
variables = {
"org": self.org.username,
Expand All @@ -436,7 +429,6 @@ def test_fetch_path_contents_with_files_and_path_prefix(
},
}
report_mock.return_value = MockReport()
critical_files.return_value = [CriticalFile("folder/fileB.py")]

data = self.gql_request(query_files, variables=variables)

Expand All @@ -457,7 +449,7 @@ def test_fetch_path_contents_with_files_and_path_prefix(
"partials": 0,
"lines": 10,
"percentCovered": 80.0,
"isCriticalFile": True,
"isCriticalFile": False,
},
{
"__typename": "PathContentDir",
Expand All @@ -477,12 +469,10 @@ def test_fetch_path_contents_with_files_and_path_prefix(
}
}

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_path_contents_with_files_and_search_value_case_insensitive(
self, report_mock, critical_files
self,
report_mock,
):
variables = {
"org": self.org.username,
Expand All @@ -494,7 +484,6 @@ def test_fetch_path_contents_with_files_and_search_value_case_insensitive(
},
}
report_mock.return_value = MockReport()
critical_files.return_value = [CriticalFile("folder/fileB.py")]

data = self.gql_request(query_files, variables=variables)

Expand Down Expand Up @@ -526,7 +515,7 @@ def test_fetch_path_contents_with_files_and_search_value_case_insensitive(
"partials": 0,
"lines": 10,
"percentCovered": 80.0,
"isCriticalFile": True,
"isCriticalFile": False,
},
],
}
Expand Down Expand Up @@ -1147,13 +1136,9 @@ def test_fetch_path_contents_component_flags_filters(
}
}

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_path_contents_deprecated(self, report_mock, critical_files_mock):
def test_fetch_path_contents_deprecated(self, report_mock):
report_mock.return_value = MockReport()
critical_files_mock.return_value = []

variables = {
"org": self.org.username,
Expand Down Expand Up @@ -1212,15 +1197,12 @@ def test_fetch_path_contents_deprecated(self, report_mock, critical_files_mock):
}
}

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_path_contents_deprecated_paginated(
self, report_mock, critical_files_mock
self,
report_mock,
):
report_mock.return_value = MockReport()
critical_files_mock.return_value = []

variables = {
"org": self.org.username,
Expand Down
59 changes: 12 additions & 47 deletions graphql_api/tests/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
)
from services.comparison import MissingComparisonReport
from services.components import Component
from services.profiling import CriticalFile

from .helper import GraphQLTestHelper, paginate_connection

Expand Down Expand Up @@ -523,13 +522,10 @@ def test_fetch_commit_yaml_call_the_command(self, command_mock):
commit = data["owner"]["repository"]["commit"]
assert commit["yaml"] == yaml.dump(fake_config)

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("core.commands.commit.commit.CommitCommands.get_file_content")
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_commit_coverage_file_call_the_command(
self, report_mock, content_mock, critical_files
self, report_mock, content_mock
):
query = (
query_commit
Expand All @@ -551,7 +547,6 @@ def test_fetch_commit_coverage_file_call_the_command(
"totals": {"percentCovered": 83.0},
}
content_mock.return_value = "file content"
critical_files.return_value = [CriticalFile("path")]

report_mock.return_value = MockReport()
data = self.gql_request(query, variables=variables)
Expand All @@ -561,7 +556,7 @@ def test_fetch_commit_coverage_file_call_the_command(
assert coverageFile["content"] == fake_coverage["content"]
assert coverageFile["coverage"] == fake_coverage["coverage"]
assert coverageFile["totals"] == fake_coverage["totals"]
assert coverageFile["isCriticalFile"] == True
assert coverageFile["isCriticalFile"] == False
assert coverageFile["hashedPath"] == hashlib.md5("path".encode()).hexdigest()

@patch("services.components.component_filtered_report")
Expand Down Expand Up @@ -648,13 +643,12 @@ def test_fetch_commit_coverage_file_with_components(
}
}

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("core.commands.commit.commit.CommitCommands.get_file_content")
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_commit_with_no_coverage_data(
self, report_mock, content_mock, critical_files
self,
report_mock,
content_mock,
):
query = (
query_commit
Expand All @@ -668,7 +662,6 @@ def test_fetch_commit_with_no_coverage_data(
}
fake_coverage = {"content": "file content", "coverage": [], "totals": None}
content_mock.return_value = "file content"
critical_files.return_value = []

report_mock.return_value = EmptyReport()
data = self.gql_request(query, variables=variables)
Expand Down Expand Up @@ -2201,30 +2194,6 @@ def test_compare_with_parent_missing_change_coverage(self):
commit = data["owner"]["repository"]["commit"]
assert commit["compareWithParent"]["changeCoverage"] is None

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
def test_commit_critical_files(self, critical_files):
critical_files.return_value = [
CriticalFile("one"),
CriticalFile("two"),
CriticalFile("three"),
]

query = query_commit % "criticalFiles { name }"
variables = {
"org": self.org.username,
"repo": self.repo.name,
"commit": self.commit.commitid,
}
data = self.gql_request(query, variables=variables)
commit = data["owner"]["repository"]["commit"]
assert commit["criticalFiles"] == [
{"name": "one"},
{"name": "two"},
{"name": "three"},
]

def test_commit_yaml_errors(self):
CommitErrorFactory(commit=self.commit, error_code="invalid_yaml")
CommitErrorFactory(commit=self.commit, error_code="yaml_client_error")
Expand Down Expand Up @@ -2649,13 +2618,12 @@ def test_coverage_totals(self):
commit = data["owner"]["repository"]["commit"]
assert commit["coverageAnalytics"]["totals"]["percentCovered"] == 12

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("core.commands.commit.commit.CommitCommands.get_file_content")
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_commit_coverage_coverage_file(
self, report_mock, content_mock, critical_files
self,
report_mock,
content_mock,
):
query = (
query_commit
Expand All @@ -2677,7 +2645,6 @@ def test_fetch_commit_coverage_coverage_file(
"totals": {"percentCovered": 83.0},
}
content_mock.return_value = "file content"
critical_files.return_value = [CriticalFile("path")]

report_mock.return_value = MockReport()
data = self.gql_request(query, variables=variables)
Expand All @@ -2687,7 +2654,7 @@ def test_fetch_commit_coverage_coverage_file(
assert coverageFile["content"] == fake_coverage["content"]
assert coverageFile["coverage"] == fake_coverage["coverage"]
assert coverageFile["totals"] == fake_coverage["totals"]
assert coverageFile["isCriticalFile"] == True
assert coverageFile["isCriticalFile"] == False
assert coverageFile["hashedPath"] == hashlib.md5("path".encode()).hexdigest()

@patch("services.components.component_filtered_report")
Expand Down Expand Up @@ -2774,13 +2741,12 @@ def test_fetch_commit_coverage_coverage_file_with_components(
}
}

@patch(
"services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
)
@patch("core.commands.commit.commit.CommitCommands.get_file_content")
@patch("shared.reports.api_report_service.build_report_from_commit")
def test_fetch_commit_coverage_with_no_coverage_data(
self, report_mock, content_mock, critical_files
self,
report_mock,
content_mock,
):
query = (
query_commit
Expand All @@ -2794,7 +2760,6 @@ def test_fetch_commit_coverage_with_no_coverage_data(
}
fake_coverage = {"content": "file content", "coverage": [], "totals": None}
content_mock.return_value = "file content"
critical_files.return_value = []

report_mock.return_value = EmptyReport()
data = self.gql_request(query, variables=variables)
Expand Down
Loading
Loading