feat: крролик, по тщ 5 лаба
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""Общие проверки для собственных black-box тестов"""
|
||||
|
||||
import base64
|
||||
import json
|
||||
import io
|
||||
import json
|
||||
import struct
|
||||
import subprocess
|
||||
import uuid
|
||||
@@ -212,5 +212,28 @@ def container_json(service: str, script: str) -> dict:
|
||||
|
||||
def run_janitor(*args: str) -> dict:
|
||||
"""Один проход janitor внутри его контейнера; отчёт сверки"""
|
||||
output = compose("exec", "-T", "janitor", "python", "src/janitor.py", "--once", *args)
|
||||
output = compose(
|
||||
"exec", "-T", "janitor", "python", "src/janitor.py", "--once", *args
|
||||
)
|
||||
return last_json_line(output)
|
||||
|
||||
|
||||
def wait_attachment(
|
||||
api: httpx.Client,
|
||||
user: dict,
|
||||
attachment_id: str,
|
||||
terminal: str = "ready",
|
||||
timeout: float = 60,
|
||||
) -> dict:
|
||||
import time
|
||||
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
response = api.get(f"/api/v1/attachments/{attachment_id}", headers=auth(user))
|
||||
assert response.status_code == 200, response.text
|
||||
result = response.json()
|
||||
if result["status"] in {"ready", "failed"}:
|
||||
assert result["status"] == terminal, result
|
||||
return result
|
||||
time.sleep(0.1)
|
||||
raise AssertionError(f"Вложение {attachment_id} не достигло {terminal}")
|
||||
|
||||
Reference in New Issue
Block a user