Skip to content

Commit 42396ce

Browse files
committed
tests
1 parent 3d45d74 commit 42396ce

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

tests/sentry/integrations/github/tasks/test_link_all_repos.py

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ def test_link_all_repos(self, mock_record: MagicMock, _: MagicMock) -> None:
8181
assert repos[0].name == "getsentry/sentry"
8282
assert repos[1].name == "getsentry/snuba"
8383

84-
assert_slo_metric(mock_record, EventLifecycleOutcome.SUCCESS)
84+
assert len(mock_record.mock_calls) == 4
85+
start1, start2, end2, end1 = mock_record.mock_calls
86+
assert start1.args[0] == EventLifecycleOutcome.STARTED
87+
assert start2.args[0] == EventLifecycleOutcome.STARTED
88+
assert end2.args[0] == EventLifecycleOutcome.SUCCESS
89+
assert end1.args[0] == EventLifecycleOutcome.SUCCESS
8590

8691
@responses.activate
8792
@patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
@@ -121,7 +126,12 @@ def test_link_all_repos_api_response_keyerror(
121126

122127
assert repos[0].name == "getsentry/snuba"
123128

124-
assert_slo_metric(mock_record, EventLifecycleOutcome.HALTED)
129+
assert len(mock_record.mock_calls) == 4
130+
start1, start2, end2, end1 = mock_record.mock_calls
131+
assert start1.args[0] == EventLifecycleOutcome.STARTED
132+
assert start2.args[0] == EventLifecycleOutcome.STARTED
133+
assert end2.args[0] == EventLifecycleOutcome.SUCCESS
134+
assert end1.args[0] == EventLifecycleOutcome.HALTED
125135
assert_halt_metric(
126136
mock_record, LinkAllReposHaltReason.REPOSITORY_NOT_CREATED.value
127137
) # should be halt because it didn't complete successfully
@@ -155,7 +165,12 @@ def test_link_all_repos_api_response_keyerror_single_repo(
155165
repos = Repository.objects.all()
156166
assert len(repos) == 0
157167

158-
assert_slo_metric(mock_record, EventLifecycleOutcome.HALTED)
168+
assert len(mock_record.mock_calls) == 4
169+
start1, start2, end2, end1 = mock_record.mock_calls
170+
assert start1.args[0] == EventLifecycleOutcome.STARTED
171+
assert start2.args[0] == EventLifecycleOutcome.STARTED
172+
assert end2.args[0] == EventLifecycleOutcome.SUCCESS
173+
assert end1.args[0] == EventLifecycleOutcome.HALTED
159174
assert_halt_metric(mock_record, LinkAllReposHaltReason.REPOSITORY_NOT_CREATED.value)
160175

161176
@patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
@@ -198,7 +213,12 @@ def test_link_all_repos_api_error(self, mock_record: MagicMock, _: MagicMock) ->
198213
organization_id=self.organization.id,
199214
)
200215

201-
assert_slo_metric(mock_record, EventLifecycleOutcome.FAILURE)
216+
assert len(mock_record.mock_calls) == 4
217+
start1, start2, end2, end1 = mock_record.mock_calls
218+
assert start1.args[0] == EventLifecycleOutcome.STARTED
219+
assert start2.args[0] == EventLifecycleOutcome.STARTED
220+
assert end2.args[0] == EventLifecycleOutcome.FAILURE
221+
assert end1.args[0] == EventLifecycleOutcome.FAILURE
202222

203223
@patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
204224
@responses.activate
@@ -221,7 +241,12 @@ def test_link_all_repos_api_error_rate_limited(
221241
organization_id=self.organization.id,
222242
)
223243

224-
assert_slo_metric(mock_record, EventLifecycleOutcome.HALTED)
244+
assert len(mock_record.mock_calls) == 4
245+
start1, start2, end2, end1 = mock_record.mock_calls
246+
assert start1.args[0] == EventLifecycleOutcome.STARTED
247+
assert start2.args[0] == EventLifecycleOutcome.STARTED
248+
assert end2.args[0] == EventLifecycleOutcome.FAILURE
249+
assert end1.args[0] == EventLifecycleOutcome.HALTED
225250
assert_halt_metric(mock_record, LinkAllReposHaltReason.RATE_LIMITED.value)
226251

227252
@patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
@@ -240,7 +265,12 @@ def test_link_all_repos_repo_creation_error(
240265
organization_id=self.organization.id,
241266
)
242267

243-
assert_slo_metric(mock_record, EventLifecycleOutcome.HALTED)
268+
assert len(mock_record.mock_calls) == 4
269+
start1, start2, end2, end1 = mock_record.mock_calls
270+
assert start1.args[0] == EventLifecycleOutcome.STARTED
271+
assert start2.args[0] == EventLifecycleOutcome.STARTED
272+
assert end2.args[0] == EventLifecycleOutcome.SUCCESS
273+
assert end1.args[0] == EventLifecycleOutcome.HALTED
244274
assert_halt_metric(mock_record, LinkAllReposHaltReason.REPOSITORY_NOT_CREATED.value)
245275

246276
@patch("sentry.integrations.utils.metrics.EventLifecycle.record_event")
@@ -262,4 +292,9 @@ def test_link_all_repos_repo_creation_exception(
262292
organization_id=self.organization.id,
263293
)
264294

265-
assert_slo_metric(mock_record, EventLifecycleOutcome.FAILURE)
295+
assert len(mock_record.mock_calls) == 4
296+
start1, start2, end2, end1 = mock_record.mock_calls
297+
assert start1.args[0] == EventLifecycleOutcome.STARTED
298+
assert start2.args[0] == EventLifecycleOutcome.STARTED
299+
assert end2.args[0] == EventLifecycleOutcome.SUCCESS
300+
assert end1.args[0] == EventLifecycleOutcome.FAILURE

0 commit comments

Comments
 (0)