watchdock-errors 0.5.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {watchdock_errors-0.5.0/src/watchdock_errors.egg-info → watchdock_errors-0.5.1}/PKG-INFO +1 -1
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/celery.py +6 -1
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1/src/watchdock_errors.egg-info}/PKG-INFO +1 -1
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/SOURCES.txt +1 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/scm_file_list.json +1 -0
- watchdock_errors-0.5.1/src/watchdock_errors.egg-info/scm_version.json +8 -0
- watchdock_errors-0.5.1/tests/test_celery_schedule.py +27 -0
- watchdock_errors-0.5.0/src/watchdock_errors.egg-info/scm_version.json +0 -8
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/.github/workflows/ci.yml +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/.github/workflows/release.yml +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/.gitignore +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/README.md +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/pyproject.toml +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/setup.cfg +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/__init__.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/client.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/config.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/event.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/__init__.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/django.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/fastapi.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/utils.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/dependency_links.txt +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/requires.txt +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/top_level.txt +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/tests/test_client.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/tests/test_event.py +0 -0
- {watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/tests/test_utils.py +0 -0
{watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/celery.py
RENAMED
|
@@ -39,6 +39,7 @@ from __future__ import annotations
|
|
|
39
39
|
|
|
40
40
|
import logging
|
|
41
41
|
import threading
|
|
42
|
+
from datetime import timedelta
|
|
42
43
|
from typing import TYPE_CHECKING
|
|
43
44
|
|
|
44
45
|
import requests
|
|
@@ -230,7 +231,11 @@ def _serialize_schedule(entry) -> dict | None:
|
|
|
230
231
|
"month_of_year": schedule._orig_month_of_year,
|
|
231
232
|
}
|
|
232
233
|
|
|
233
|
-
seconds
|
|
234
|
+
# timedelta.seconds is only the seconds component (a 1-day timedelta has 0), so use the total.
|
|
235
|
+
if isinstance(schedule, timedelta):
|
|
236
|
+
seconds = schedule.total_seconds()
|
|
237
|
+
else:
|
|
238
|
+
seconds = getattr(schedule, "seconds", schedule) # celery.schedules.schedule or plain number
|
|
234
239
|
try:
|
|
235
240
|
return {"type": "interval", "every_seconds": float(seconds)}
|
|
236
241
|
except (TypeError, ValueError):
|
|
@@ -19,6 +19,7 @@ src/watchdock_errors/integrations/__init__.py
|
|
|
19
19
|
src/watchdock_errors/integrations/celery.py
|
|
20
20
|
src/watchdock_errors/integrations/django.py
|
|
21
21
|
src/watchdock_errors/integrations/fastapi.py
|
|
22
|
+
tests/test_celery_schedule.py
|
|
22
23
|
tests/test_client.py
|
|
23
24
|
tests/test_event.py
|
|
24
25
|
tests/test_utils.py
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from datetime import timedelta
|
|
2
|
+
from types import SimpleNamespace
|
|
3
|
+
|
|
4
|
+
from watchdock_errors.integrations.celery import _serialize_schedule
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_number_is_an_interval():
|
|
8
|
+
assert _serialize_schedule({"schedule": 300}) == {"type": "interval", "every_seconds": 300.0}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_timedelta_uses_total_seconds():
|
|
12
|
+
assert _serialize_schedule({"schedule": timedelta(minutes=5)})["every_seconds"] == 300.0
|
|
13
|
+
assert _serialize_schedule({"schedule": timedelta(days=1)})["every_seconds"] == 86400.0
|
|
14
|
+
assert _serialize_schedule({"schedule": timedelta(days=1, hours=2)})["every_seconds"] == 93600.0
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_celery_schedule_object_uses_its_seconds():
|
|
18
|
+
assert _serialize_schedule({"schedule": SimpleNamespace(seconds=86400.0)})["every_seconds"] == 86400.0
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_crontab_is_not_an_interval():
|
|
22
|
+
cron = SimpleNamespace(_orig_minute="0", _orig_hour="3", _orig_day_of_week="*", _orig_day_of_month="*", _orig_month_of_year="*")
|
|
23
|
+
assert _serialize_schedule({"schedule": cron})["type"] == "crontab"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_missing_schedule():
|
|
27
|
+
assert _serialize_schedule({}) is None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/__init__.py
RENAMED
|
File without changes
|
{watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/django.py
RENAMED
|
File without changes
|
{watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors/integrations/fastapi.py
RENAMED
|
File without changes
|
|
File without changes
|
{watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/requires.txt
RENAMED
|
File without changes
|
{watchdock_errors-0.5.0 → watchdock_errors-0.5.1}/src/watchdock_errors.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|