Skip to content

Commit 1e81de1

Browse files
committed
fix tests
1 parent 04a68a6 commit 1e81de1

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/integrations/celery/test_celery_beat_crons.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def test_get_monitor_config_crontab():
213213
app.conf.timezone = "Europe/Vienna"
214214

215215
celery_schedule = crontab(day_of_month="3", hour="12", minute="*/10")
216-
monitor_config = _get_monitor_config(celery_schedule, app)
216+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
217217
assert monitor_config == {
218218
"schedule": {
219219
"type": "crontab",
@@ -230,8 +230,17 @@ def test_get_monitor_config_seconds():
230230
app.conf.timezone = "Europe/Vienna"
231231

232232
celery_schedule = schedule(run_every=3) # seconds
233-
monitor_config = _get_monitor_config(celery_schedule, app)
234-
assert monitor_config == {}
233+
234+
with mock.patch(
235+
"sentry_sdk.integrations.celery.logger.warning"
236+
) as mock_logger_warning:
237+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
238+
mock_logger_warning.assert_called_with(
239+
"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.",
240+
"foo",
241+
3,
242+
)
243+
assert monitor_config == {}
235244

236245

237246
def test_get_monitor_config_minutes():
@@ -240,7 +249,7 @@ def test_get_monitor_config_minutes():
240249
app.conf.timezone = "Europe/Vienna"
241250

242251
celery_schedule = schedule(run_every=60) # seconds
243-
monitor_config = _get_monitor_config(celery_schedule, app)
252+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
244253
assert monitor_config == {
245254
"schedule": {
246255
"type": "interval",
@@ -257,7 +266,7 @@ def test_get_monitor_config_unknown():
257266
app.conf.timezone = "Europe/Vienna"
258267

259268
unknown_celery_schedule = MagicMock()
260-
monitor_config = _get_monitor_config(unknown_celery_schedule, app)
269+
monitor_config = _get_monitor_config(unknown_celery_schedule, app, "foo")
261270
assert monitor_config == {}
262271

263272

@@ -268,7 +277,7 @@ def test_get_monitor_config_default_timezone():
268277

269278
celery_schedule = crontab(day_of_month="3", hour="12", minute="*/10")
270279

271-
monitor_config = _get_monitor_config(celery_schedule, app)
280+
monitor_config = _get_monitor_config(celery_schedule, app, "foo")
272281

273282
assert monitor_config["timezone"] == "UTC"
274283

0 commit comments

Comments
 (0)