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

Commit ca08f95

Browse files
committed
Fix tests
1 parent e1f0ec1 commit ca08f95

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

upload/tests/views/test_bundle_analysis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def test_upload_bundle_analysis_success(db, client, mocker, mock_redis):
2727
"shared.api_archive.archive.StorageService.create_presigned_put",
2828
return_value="test-presigned-put",
2929
)
30-
mock_amplitude = mocker.patch("shared.events.amplitude.AmplitudeEventPublisher")
30+
mock_amplitude = mocker.patch(
31+
"shared.events.amplitude.AmplitudeEventPublisher.publish"
32+
)
3133

3234
repository = RepositoryFactory.create()
3335
commit_sha = "6fd5b89357fc8cdf34d6197549ac7c6d7e5977ef"
@@ -105,7 +107,7 @@ def test_upload_bundle_analysis_success(db, client, mocker, mock_redis):
105107
)
106108

107109
# emits Amplitude event
108-
mock_amplitude.return_value.publish.assert_called_with(
110+
mock_amplitude.assert_called_with(
109111
"Upload Sent",
110112
{
111113
"user_ownerid": commit.repository.author.ownerid,

upload/tests/views/test_test_results.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def test_upload_test_results(db, client, mocker, mock_redis):
2525
"shared.api_archive.archive.StorageService.create_presigned_put",
2626
return_value="test-presigned-put",
2727
)
28-
mock_amplitude = mocker.patch("shared.events.amplitude.AmplitudeEventPublisher")
28+
mock_amplitude = mocker.patch(
29+
"shared.events.amplitude.AmplitudeEventPublisher.publish"
30+
)
2931

3032
owner = OwnerFactory(service="github", username="codecov")
3133
repository = RepositoryFactory.create(author=owner)
@@ -117,7 +119,7 @@ def test_upload_test_results(db, client, mocker, mock_redis):
117119
)
118120

119121
# emits Amplitude event
120-
mock_amplitude.return_value.publish.assert_called_with(
122+
mock_amplitude.assert_called_with(
121123
"Upload Sent",
122124
{
123125
"user_ownerid": commit.repository.author.ownerid,

upload/tests/views/test_uploads.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ def test_uploads_post_tokenless(db, mocker, mock_redis, private, branch, branch_
314314
"upload.views.uploads.trigger_upload_task", return_value=True
315315
)
316316
analytics_service_mock = mocker.patch("upload.views.uploads.AnalyticsService")
317-
amplitude_mock = mocker.path("shared.events.amplitude.AmplitudeEventPublisher")
317+
amplitude_mock = mocker.patch(
318+
"shared.events.amplitude.AmplitudeEventPublisher.publish"
319+
)
318320

319321
repository = RepositoryFactory(
320322
name="the_repo",
@@ -432,7 +434,7 @@ def test_uploads_post_tokenless(db, mocker, mock_redis, private, branch, branch_
432434
"uploader_type": "CLI",
433435
},
434436
)
435-
amplitude_mock.return_value.publish.assert_called_with(
437+
amplitude_mock.assert_called_with(
436438
"Upload Sent",
437439
{
438440
"user_ownerid": commit.repository.author.ownerid,
@@ -471,7 +473,9 @@ def test_uploads_post_token_required_auth_check(
471473
"upload.views.uploads.trigger_upload_task", return_value=True
472474
)
473475
analytics_service_mock = mocker.patch("upload.views.uploads.AnalyticsService")
474-
amplitude_mock = mocker.path("shared.events.amplitude.AmplitudeEventPublisher")
476+
amplitude_mock = mocker.patch(
477+
"shared.events.amplitude.AmplitudeEventPublisher.publish"
478+
)
475479

476480
repository = RepositoryFactory(
477481
name="the_repo",
@@ -596,7 +600,7 @@ def test_uploads_post_token_required_auth_check(
596600
"uploader_type": "CLI",
597601
},
598602
)
599-
amplitude_mock.return_value.publish.assert_called_with(
603+
amplitude_mock.assert_called_with(
600604
"Upload Sent",
601605
{
602606
"user_ownerid": commit.repository.author.ownerid,
@@ -612,7 +616,7 @@ def test_uploads_post_token_required_auth_check(
612616
assert response.json().get("detail") == "Not valid tokenless upload"
613617

614618

615-
@patch("shared.events.amplitude.AmplitudeEventPublisher")
619+
@patch("shared.events.amplitude.AmplitudeEventPublisher.publish")
616620
@patch("upload.views.uploads.AnalyticsService")
617621
@patch("upload.helpers.jwt.decode")
618622
@patch("upload.helpers.PyJWKClient")
@@ -743,7 +747,7 @@ def test_uploads_post_github_oidc_auth(
743747
"uploader_type": "CLI",
744748
},
745749
)
746-
amplitude_mock.return_value.publish.assert_called_with(
750+
amplitude_mock.assert_called_with(
747751
"Upload Sent",
748752
{
749753
"user_ownerid": commit.repository.author.ownerid,

0 commit comments

Comments
 (0)