Skip to content

Commit bec6518

Browse files
author
marekbiczysko
committed
cov, migration
1 parent 89cbaf3 commit bec6518

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated by Django 5.2.12 on 2026-04-15 07:04
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("core", "0021_asyncjob_queue_name"),
9+
]
10+
11+
operations = [
12+
migrations.CreateModel(
13+
name="PeriodicAsyncJob",
14+
fields=[],
15+
options={
16+
"verbose_name": "Periodic Asynchronous Job",
17+
"verbose_name_plural": "Periodic Asynchronous Jobs",
18+
"proxy": True,
19+
"indexes": [],
20+
"constraints": [],
21+
},
22+
bases=("core.asyncjob",),
23+
),
24+
migrations.CreateModel(
25+
name="PeriodicAsyncRetryJob",
26+
fields=[],
27+
options={
28+
"verbose_name": "Periodic Retry Asynchronous Job",
29+
"verbose_name_plural": "Periodic Retry Asynchronous Jobs",
30+
"proxy": True,
31+
"indexes": [],
32+
"constraints": [],
33+
},
34+
bases=("core.asyncretryjob",),
35+
),
36+
migrations.AlterModelOptions(
37+
name="asyncjob",
38+
options={
39+
"permissions": (("debug_job", "Can debug background jobs"),),
40+
"verbose_name": "Asynchronous Job",
41+
"verbose_name_plural": "Asynchronous Jobs",
42+
},
43+
),
44+
]

tests/unit/apps/core/test_celery_tasks.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,26 @@ def test_async_job_queue_uses_queue_name_and_flower_metadata() -> None:
231231
mock_set_queued.assert_called_once_with(job, result)
232232

233233

234+
def test_async_job_queue_returns_none_for_active_jobs() -> None:
235+
job = AsyncJob(
236+
type="JOB_TASK",
237+
action="unit.apps.core.test_celery_tasks.fake_async_job_action",
238+
config={},
239+
repeatable=True,
240+
)
241+
242+
with (
243+
patch.object(AsyncJob, "task_status", new_callable=PropertyMock, return_value=job.QUEUED),
244+
patch("hope.apps.core.celery_tasks.async_job_task.apply_async") as mock_apply_async,
245+
patch.object(AsyncJob, "set_queued", autospec=True) as mock_set_queued,
246+
):
247+
queue_result = job.queue()
248+
249+
assert queue_result is None
250+
mock_apply_async.assert_not_called()
251+
mock_set_queued.assert_not_called()
252+
253+
234254
@pytest.mark.django_db
235255
def test_celery_configuration_uses_shared_queue_constants() -> None:
236256
assert {queue.name for queue in app.conf["task_queues"]} == {

0 commit comments

Comments
 (0)