Files
mtusi2026lab5-fork/student_tests/outbox.py
T
2026-11-16 20:30:12 +03:00

32 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Outbox: пауза outbox → 202 → unpause → ready; published_at=NULL в промежутке."""
import sys, time
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from tests.client import Client, check
from student_tests.common import upload, wait_status, psql, docker, ok, fail
def main():
c = Client()
a, b, e, ch = c.bootstrap()
content = Path('tests/fixtures/sample.png').read_bytes()
docker('pause', 'outbox')
try:
att = upload(c, a, ch, content)
check(att['status'] == 'queued', 'expected queued')
time.sleep(3)
published = psql("SELECT coalesce(published_at::text,'NULL') FROM attachment_jobs WHERE attachment_id='%s'" % att['id'])
check(published == 'NULL', 'outbox paused but published_at=%s' % published)
ok('outbox paused: published_at IS NULL, upload accepted')
finally:
docker('unpause', 'outbox')
att = wait_status(c, a, att['id'], 'ready', seconds=90)
ok('after unpause: ready')
if __name__ == '__main__':
try:
main()
except Exception as exc:
fail(str(exc))