Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Aug 18, 2024
1 parent 7b89bf7 commit bcba8d3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/test_task_celery_wrapup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from celery import Task, group
from celery import Task

from .celery_tasks import task_get_time

Expand All @@ -12,10 +12,9 @@ def test_task_get_time() -> None:
results: dict[int, float] = {}
tasks: list[Task] = []

for i in range(1, 11):
promise = group([task_get_time.s(request_id=i)])
breakpoint()
tasks.append(promise.apply_async())
for i in range(10):
task_promise = task_get_time.s(request_id=i)
tasks.append(task_promise.apply_async())

for task in tasks:
task_id, result = task.get(timeout=10)
Expand All @@ -35,9 +34,11 @@ def test_task_get_time() -> None:
)

previous_time = results[0]
tol = 0.2
for i in sorted(results.keys()):
result = results[i]
current_time = result
assert current_time - previous_time > diffs[i][0]
assert current_time - previous_time < diffs[i][1]
diff = current_time - previous_time
assert diff >= diffs[i][0] - tol
assert diff <= diffs[i][1] + tol
previous_time = current_time

0 comments on commit bcba8d3

Please sign in to comment.