Skip to content

Commit

Permalink
formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntindicator committed Oct 15, 2024
1 parent a9a7490 commit 9be2125
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions django_celery_beat/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,19 @@ def run_tasks(self, request, queryset):
)
return


task_ids = [
task.apply_async(args=args, kwargs=kwargs, queue=queue,
headers={'periodic_task_name':periodic_task_name})
task.apply_async(
args=args,
kwargs=kwargs,
queue=queue,
headers={'periodic_task_name': periodic_task_name}
)
if queue and len(queue)
else task.apply_async(args=args, kwargs=kwargs,
headers={'periodic_task_name':periodic_task_name})
else task.apply_async(
args=args,
kwargs=kwargs,
headers={'periodic_task_name': periodic_task_name}
)
for task, args, kwargs, queue, periodic_task_name in tasks
]
tasks_run = len(task_ids)
Expand Down
4 changes: 2 additions & 2 deletions t/unit/test_schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,13 +870,13 @@ def test_run_tasks(self):
queued_message = self.request._messages._queued_messages[0].message
assert queued_message == '2 tasks were successfully run'


@pytest.mark.timeout(5)
def test_run_task_headers(self, monkeypatch):
def mock_apply_async(*args, **kwargs):
self.captured_headers = kwargs.get('headers', {})

monkeypatch.setattr('celery.app.task.Task.apply_async', mock_apply_async)
monkeypatch.setattr('celery.app.task.Task.apply_async',
mock_apply_async)
ma = PeriodicTaskAdmin(PeriodicTask, self.site)
self.request = self.patch_request(self.request_factory.get('/'))
ma.run_tasks(self.request, PeriodicTask.objects.filter(id=self.m1.id))
Expand Down

0 comments on commit 9be2125

Please sign in to comment.