Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjo100 committed Sep 8, 2023
1 parent 3d4bd24 commit e43d5f4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/sentry/monitors/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import mock

import msgpack
import pytest
from arroyo.backends.kafka import KafkaPayload
from django.test import override_settings
from django.utils import timezone
Expand Down Expand Up @@ -291,9 +292,8 @@ def test_not_missing_checkin(self):
monitor_environment=monitor_environment.id, status=CheckInStatus.MISSED
).exists()

@mock.patch("sentry.monitors.tasks.logger")
@mock.patch("sentry.monitors.tasks.check_missing_environment")
def test_missed_exception_handling(self, check_missing_environment_mock, logger):
def test_missed_exception_handling(self, check_missing_environment_mock):
org = self.create_organization()
project = self.create_project(organization=org)

Expand Down Expand Up @@ -337,11 +337,12 @@ def test_missed_exception_handling(self, check_missing_environment_mock, logger)
# assert that task is called for the specific environments
assert check_missing_environment_mock.delay.call_count == 2

for monitor_environment in [failing_monitor_environment, successful_monitor_environment]:
check_missing_environment(monitor_environment.id)
# assert failing monitor raises an error
with pytest.raises(ValueError):
check_missing_environment(failing_monitor_environment.id)

# Logged the exception
assert logger.exception.call_count == 1
# assert regular monitor works
check_missing_environment(successful_monitor_environment.id)

# We still marked a monitor as missed
assert MonitorEnvironment.objects.filter(
Expand Down

0 comments on commit e43d5f4

Please sign in to comment.