Skip to content
Snippets Groups Projects
Commit a50db05d authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

Add celery worker and celery beat

parent c530567b
No related branches found
No related tags found
No related merge requests found
Pipeline #84457 failed
from unittest.mock import patch
import pytest
from gso.schedules.scheduling import scheduler
@pytest.fixture
def mock_celery():
with patch("gso.schedules.scheduling.current_app") as mock_app:
yield mock_app
def test_scheduler_updates_beat_schedule(mock_celery):
mock_celery.conf.beat_schedule = {}
@scheduler(name="A cool task", minute="0", hour="0", day_of_week="*", day_of_month="*", month_of_year="*")
def mock_task():
return "task result"
assert "mock_task" in mock_celery.conf.beat_schedule
scheduled = mock_celery.conf.beat_schedule["mock_task"]
assert scheduled["schedule"].minute == {0}
assert scheduled["schedule"].hour == {0}
assert scheduled["task"] == "test.schedules.test_scheduling.mock_task"
assert scheduled["name"] == "A cool task"
def test_scheduled_task_still_works():
"""Ensure that the scheduler decorator does not change the behavior of the function it decorates."""
@scheduler(name="A cool task", minute="0", hour="0", day_of_week="*", day_of_month="*", month_of_year="*")
def mock_task():
return "task result"
result = mock_task()
assert result == "task result"
...@@ -22,6 +22,7 @@ deps = ...@@ -22,6 +22,7 @@ deps =
ruff ruff
isort isort
types-requests types-requests
celery-stubs
-r requirements.txt -r requirements.txt
commands = commands =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment