Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle flare when commit report not available #520

Merged
merged 2 commits into from
Apr 24, 2024
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
33 changes: 33 additions & 0 deletions graphs/tests/test_graph_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,3 +657,36 @@ def test_pull_no_repo_graph(self):
response.data["detail"]
== "Not found. Note: private repositories require ?token arguments"
)

@patch("services.report.build_report_from_commit")
def test_pull_file_not_found_in_storage(self, mocked_build_report):
mocked_build_report.return_value = None
gh_owner = OwnerFactory(service="github")
repo = RepositoryFactory(
author=gh_owner,
active=True,
private=True,
name="repo1",
image_token="12345678",
branch="master",
)
CommitWithReportFactory(repository=repo, author=gh_owner)
PullFactory(pullid=10, repository_id=repo.repoid, _flare=None)

response = self._get_pull(
"tree",
kwargs={
"service": "gh",
"owner_username": gh_owner.username,
"repo_name": "repo1",
"ext": "svg",
"pull": 10,
},
data={"token": "12345678"},
)

assert response.status_code == status.HTTP_404_NOT_FOUND
assert (
response.data["detail"]
== "Not found. Note: file for chunks not found in storage"
)
4 changes: 4 additions & 0 deletions graphs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ def get_commit_flare(self):
)

report = report_service.build_report_from_commit(commit)

if report is None:
raise NotFound("Not found. Note: file for chunks not found in storage")

return report.flare(None, [70, 100])

def get_pull_flare(self, pullid):
Expand Down
Loading