Skip to content

Commit

Permalink
triggering pre-process upload for all users (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
dana-yaish authored Oct 12, 2023
1 parent 4c8d43b commit 5ea3b6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
22 changes: 2 additions & 20 deletions upload/tests/views/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_create_report_already_exists(client, db, mocker):


def test_reports_post_code_as_default(client, db, mocker):
mocked_call = mocker.patch.object(TaskService, "preprocess_upload")
repository = RepositoryFactory(
name="the_repo", author__username="codecov", author__service="github"
)
Expand All @@ -84,6 +85,7 @@ def test_reports_post_code_as_default(client, db, mocker):
)
assert response.status_code == 201
assert CommitReport.objects.filter(commit_id=commit.id, code=None).exists()
mocked_call.assert_called_once()


def test_reports_results_post_successful(client, db, mocker):
Expand Down Expand Up @@ -222,23 +224,3 @@ def test_report_results_get_unsuccessful(client, db, mocker):
)
assert response.status_code == 400
assert response.json() == ["Report Results not found"]


def test_not_called_preprocess_upload_task(client, db, mocker):
mocked_call = mocker.patch.object(TaskService, "preprocess_upload")
repository = RepositoryFactory(
name="the_repo", author__username="not_codecov", author__service="github"
)
commit = CommitFactory(repository=repository)
repository.save()
client = APIClient()
client.credentials(HTTP_AUTHORIZATION="token " + repository.upload_token)
url = reverse(
"new_upload.reports",
args=["github", "not_codecov::::the_repo", commit.commitid],
)
response = client.post(url, data={"code": "code1"})

assert response.status_code == 201
assert CommitReport.objects.filter(commit_id=commit.id, code="code1").exists()
mocked_call.assert_not_called()
7 changes: 3 additions & 4 deletions upload/views/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ def perform_create(self, serializer):
instance = serializer.save(
commit_id=commit.id,
)
if repository.author.username == "codecov":
TaskService().preprocess_upload(
repository.repoid, commit.commitid, instance.code
)
TaskService().preprocess_upload(
repository.repoid, commit.commitid, instance.code
)
return instance

def list(self, request: HttpRequest, service: str, repo: str, commit_sha: str):
Expand Down

0 comments on commit 5ea3b6b

Please sign in to comment.