feat: rebuild work queue api with fastapi and postgres
Some checks failed
ci / build-test-push (push) Failing after 1m42s
Some checks failed
ci / build-test-push (push) Failing after 1m42s
This commit is contained in:
47
tests/test_api.py
Normal file
47
tests/test_api.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from datetime import datetime, UTC
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from app.db import validate_transition
|
||||
from app.models import Project, WorkItem
|
||||
|
||||
|
||||
def test_validate_transition_rules():
|
||||
validate_transition("queued", "dispatched", "steve-w", None, None)
|
||||
validate_transition("in_progress", "completed", "steve-w", "success", "done")
|
||||
with pytest.raises(Exception):
|
||||
validate_transition("queued", "dispatched", None, None, None)
|
||||
with pytest.raises(Exception):
|
||||
validate_transition("in_progress", "blocked", "steve-w", None, None)
|
||||
|
||||
|
||||
def test_models_shape():
|
||||
now = datetime.now(UTC).replace(microsecond=0)
|
||||
project = Project(
|
||||
id=uuid4(),
|
||||
name="Queue",
|
||||
external_ref=None,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
work = WorkItem(
|
||||
id=uuid4(),
|
||||
project_id=project.id,
|
||||
type="code_review",
|
||||
description="Review PR",
|
||||
payload={"pr": 3},
|
||||
priority=2,
|
||||
status="queued",
|
||||
assigned_agent="steve-w",
|
||||
created_by="marcus-a",
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
completed_at=None,
|
||||
outcome=None,
|
||||
notes=None,
|
||||
dispatch_log=[],
|
||||
)
|
||||
assert project.name == "Queue"
|
||||
assert work.priority == 2
|
||||
assert work.payload == {"pr": 3}
|
||||
Reference in New Issue
Block a user