fix: implement backend testing amendments and atomic source publication
Some checks failed
Mostovik Backend CI/CD / Tests and lint (push) Successful in 3m16s
Mostovik Backend CI/CD / Deploy dev (push) Has been cancelled
Mostovik Backend CI/CD / Deploy and verify internal main (push) Has been cancelled
Mostovik Backend CI/CD / Build linux/amd64 release images (push) Has been cancelled

This commit is contained in:
Aleksandr Meshchryakov
2026-10-12 09:47:28 +02:00
parent 2eeb237a47
commit 9b3da5b505
46 changed files with 2918 additions and 335 deletions

View File

@@ -80,9 +80,9 @@ def test_failed_run_keeps_progress_and_error_after_last_active_job_disappears():
job.fail("Ошибка загрузки")
card = SourceCardService.get_card("arbitration-cases")
assert (card["status"], card["progress"], card["error_message"]) == (
"error",
"failed",
60,
"Ошибка загрузки",
"Не удалось обновить данные. Повторите попытку позже.",
)
@@ -110,13 +110,21 @@ def test_broker_failure_keeps_all_registered_parts_in_final_failed_state():
@pytest.mark.django_db
def test_completed_new_run_does_not_hide_active_older_run():
definition = SourceCardService.get_definition("manufacturers-and-products")
specs = [(MagicMock(), name, "industrial") for name in definition.task_names]
first = SourceCardService._enqueue_refresh_group(
definition, specs, requested_by_id=None, kwargs={}
)
second = SourceCardService._enqueue_refresh_group(
definition, specs, requested_by_id=None, kwargs={}
)
# Historical overlapping runs predate the publication barrier. New refreshes
# reject this overlap, but polling must still represent existing older jobs.
def legacy_run(prefix):
ids = [f"{prefix}-{index}" for index in range(len(definition.task_names))]
for task_id, name in zip(ids, definition.task_names, strict=True):
BackgroundJob.objects.create(
task_id=task_id,
task_name=name,
meta={"source_card": definition.slug, "refresh_task_ids": ids},
)
return [{"task_id": task_id} for task_id in ids]
first = legacy_run("older")
second = legacy_run("newer")
for item in second:
BackgroundJob.objects.get(task_id=item["task_id"]).complete()
card = SourceCardService.get_card(definition.slug)