Skip to content

Commit 00afab9

Browse files
committed
fix tests
1 parent 3c3e9cb commit 00afab9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/integrations/celery/test_celery_beat_crons.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from unittest.mock import patch
12
import pytest
23

34
pytest.importorskip("celery")
@@ -213,7 +214,7 @@ def test_get_monitor_config_crontab():
213214
app.conf.timezone = "Europe/Vienna"
214215

215216
celery_schedule = crontab(day_of_month="3", hour="12", minute="*/10")
216-
monitor_config = _get_monitor_config(celery_schedule, app)
217+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
217218
assert monitor_config == {
218219
"schedule": {
219220
"type": "crontab",
@@ -224,13 +225,19 @@ def test_get_monitor_config_crontab():
224225
assert "unit" not in monitor_config["schedule"]
225226

226227

227-
def test_get_monitor_config_seconds():
228+
@patch("sentry_sdk.integrations.celery.logger.warning")
229+
def test_get_monitor_config_seconds(mock_logger_warning):
228230
app = MagicMock()
229231
app.conf = MagicMock()
230232
app.conf.timezone = "Europe/Vienna"
231233

232234
celery_schedule = schedule(run_every=3) # seconds
233-
monitor_config = _get_monitor_config(celery_schedule, app)
235+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
236+
mock_logger_warning.assert_called_with(
237+
"Intervals shorter than one minute are not supported by Sentry Crons. Monitor '%s' has an interval of %s seconds. Use the `exclude_beat_tasks` option in the celery integration to exclude it.",
238+
"foo",
239+
3,
240+
)
234241
assert monitor_config == {}
235242

236243

@@ -240,7 +247,7 @@ def test_get_monitor_config_minutes():
240247
app.conf.timezone = "Europe/Vienna"
241248

242249
celery_schedule = schedule(run_every=60) # seconds
243-
monitor_config = _get_monitor_config(celery_schedule, app)
250+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
244251
assert monitor_config == {
245252
"schedule": {
246253
"type": "interval",
@@ -257,7 +264,7 @@ def test_get_monitor_config_unknown():
257264
app.conf.timezone = "Europe/Vienna"
258265

259266
unknown_celery_schedule = MagicMock()
260-
monitor_config = _get_monitor_config(unknown_celery_schedule, app)
267+
monitor_config = _get_monitor_config(unknown_celery_schedule, app, "foo")
261268
assert monitor_config == {}
262269

263270

@@ -268,7 +275,7 @@ def test_get_monitor_config_default_timezone():
268275

269276
celery_schedule = crontab(day_of_month="3", hour="12", minute="*/10")
270277

271-
monitor_config = _get_monitor_config(celery_schedule, app)
278+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
272279

273280
assert monitor_config["timezone"] == "UTC"
274281

0 commit comments

Comments
 (0)