@@ -314,6 +314,7 @@ 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" )
317318
318319 repository = RepositoryFactory (
319320 name = "the_repo" ,
@@ -431,6 +432,17 @@ def test_uploads_post_tokenless(db, mocker, mock_redis, private, branch, branch_
431432 "uploader_type" : "CLI" ,
432433 },
433434 )
435+ amplitude_mock .return_value .publish .assert_called_with (
436+ "Upload Sent" ,
437+ {
438+ "user_ownerid" : commit .author .ownerid ,
439+ "ownerid" : commit .repository .author .ownerid ,
440+ "repoid" : commit .repository .repoid ,
441+ "commitid" : commit .id ,
442+ "pullid" : commit .pullid ,
443+ "upload_type" : "Coverage report" ,
444+ },
445+ )
434446 else :
435447 assert response .status_code == 401
436448 assert response .json ().get ("detail" ) == "Not valid tokenless upload"
@@ -459,6 +471,7 @@ def test_uploads_post_token_required_auth_check(
459471 "upload.views.uploads.trigger_upload_task" , return_value = True
460472 )
461473 analytics_service_mock = mocker .patch ("upload.views.uploads.AnalyticsService" )
474+ amplitude_mock = mocker .path ("shared.events.amplitude.AmplitudeEventPublisher" )
462475
463476 repository = RepositoryFactory (
464477 name = "the_repo" ,
@@ -583,18 +596,31 @@ def test_uploads_post_token_required_auth_check(
583596 "uploader_type" : "CLI" ,
584597 },
585598 )
599+ amplitude_mock .return_value .publish .assert_called_with (
600+ "Upload Sent" ,
601+ {
602+ "user_ownerid" : commit .author .ownerid ,
603+ "ownerid" : commit .repository .author .ownerid ,
604+ "repoid" : commit .repository .repoid ,
605+ "commitid" : commit .id ,
606+ "pullid" : commit .pullid ,
607+ "upload_type" : "Coverage report" ,
608+ },
609+ )
586610 else :
587611 assert response .status_code == 401
588612 assert response .json ().get ("detail" ) == "Not valid tokenless upload"
589613
590614
615+ @patch ("shared.events.amplitude.AmplitudeEventPublisher" )
591616@patch ("upload.views.uploads.AnalyticsService" )
592617@patch ("upload.helpers.jwt.decode" )
593618@patch ("upload.helpers.PyJWKClient" )
594619def test_uploads_post_github_oidc_auth (
595620 mock_jwks_client ,
596621 mock_jwt_decode ,
597622 analytics_service_mock ,
623+ amplitude_mock ,
598624 db ,
599625 mocker ,
600626 mock_redis ,
@@ -717,6 +743,17 @@ def test_uploads_post_github_oidc_auth(
717743 "uploader_type" : "CLI" ,
718744 },
719745 )
746+ amplitude_mock .return_value .publish .assert_called_with (
747+ "Upload Sent" ,
748+ {
749+ "user_ownerid" : commit .author .ownerid ,
750+ "ownerid" : commit .repository .author .ownerid ,
751+ "repoid" : commit .repository .repoid ,
752+ "commitid" : commit .id ,
753+ "pullid" : commit .pullid ,
754+ "upload_type" : "Coverage report" ,
755+ },
756+ )
720757
721758
722759@override_settings (SHELTER_SHARED_SECRET = "shelter-shared-secret" )
0 commit comments