Skip to content

Commit 99ec2d8

Browse files
committed
test(crons): Cover the monitor exit check-in after a dropped enter
Test written by ericapisani in review.
1 parent 0d214e6 commit 99ec2d8

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎tests/test_crons.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,31 @@ def test_capture_checkin_dropped_by_before_send(sentry_init, capture_envelopes):
334334
assert envelopes == []
335335

336336

337+
def test_context_monitor_exit_successfully_sends_checkin_when_enter_checkin_dropped(
338+
sentry_init, capture_envelopes
339+
):
340+
sentry_init(
341+
before_send=lambda event, hint: (
342+
None if event.get("status") == "in_progress" else event
343+
)
344+
)
345+
envelopes = capture_envelopes()
346+
347+
monitor = sentry_sdk.monitor(monitor_slug="abc123")
348+
with monitor:
349+
# Confirms that the check in was dropped in the `__enter__`
350+
assert monitor.check_in_id is None
351+
352+
(envelope,) = envelopes
353+
check_in = envelope.items[0].payload.json
354+
355+
# Confirms that the second check in in `__exit__` works correctly
356+
assert check_in["monitor_slug"] == "abc123"
357+
assert check_in["check_in_id"]
358+
assert check_in["status"] == "ok"
359+
assert check_in["duration"] > 0
360+
361+
337362
def test_scope_data_in_checkin(sentry_init, capture_envelopes):
338363
sentry_init()
339364
envelopes = capture_envelopes()

0 commit comments

Comments
 (0)