Skip to content

Commit 5ebe849

Browse files
committed
fix(analytics): mypy issue and test fix
1 parent d24fe2b commit 5ebe849

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/sentry/preprod/analytics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class PreprodArtifactApiAssembleEvent(analytics.Event):
66
organization_id: str
77
project_id: str
8-
user_id: str | None = None
8+
user_id: int | None = None
99

1010

1111
@analytics.eventclass("preprod_artifact.api.update")

tests/sentry/preprod/api/endpoints/test_project_preprod_artifact_assemble_generic.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
from django.test import override_settings
55

66
from sentry.models.files.fileblob import FileBlob
7+
from sentry.preprod import PreprodArtifactApiAssembleGenericEvent
78
from sentry.preprod.models import PreprodArtifact
89
from sentry.tasks.assemble import AssembleTask, ChunkFileState, set_assemble_status
910
from sentry.testutils.auth import generate_service_request_signature
1011
from sentry.testutils.cases import TestCase
12+
from sentry.testutils.helpers.analytics import assert_analytics_events_recorded
1113

1214

1315
@override_settings(LAUNCHPAD_RPC_SHARED_SECRET=["test-secret-key"])
@@ -77,10 +79,14 @@ def test_assemble_size_analysis_success(self, mock_analytics):
7779
assert resp_data["state"] == ChunkFileState.CREATED
7880
assert resp_data["missingChunks"] == []
7981

80-
mock_analytics.assert_called_once_with(
81-
"preprod_artifact.api.assemble_generic",
82-
organization_id=self.organization.id,
83-
project_id=self.project.id,
82+
assert_analytics_events_recorded(
83+
mock_analytics,
84+
[
85+
PreprodArtifactApiAssembleGenericEvent(
86+
organization_id=self.organization.id,
87+
project_id=self.project.id,
88+
)
89+
],
8490
)
8591
self._assert_task_called_with(mock_task, checksum, [b.checksum for b in blobs])
8692

@@ -104,10 +110,14 @@ def test_assemble_installable_app_success(self, mock_analytics):
104110
assert resp_data["state"] == ChunkFileState.CREATED
105111
assert resp_data["missingChunks"] == []
106112

107-
mock_analytics.assert_called_once_with(
108-
"preprod_artifact.api.assemble_generic",
109-
organization_id=self.organization.id,
110-
project_id=self.project.id,
113+
assert_analytics_events_recorded(
114+
mock_analytics,
115+
[
116+
PreprodArtifactApiAssembleGenericEvent(
117+
organization_id=self.organization.id,
118+
project_id=self.project.id,
119+
)
120+
],
111121
)
112122
self._assert_task_called_with(mock_task, checksum, [b.checksum for b in blobs])
113123

0 commit comments

Comments
 (0)