"""Integration: ticket flow test — Go/Gin backend.""" import pytest from httpx import AsyncClient from tests.conftest import auth_header class TestTicketFlow: async def test_create_and_get_ticket(self, client: AsyncClient, admin_token: str, test_mysql_instance): import uuid suffix = uuid.uuid4().hex[:6] # Create resp = await client.post("/api/v1/tickets", headers=auth_header(admin_token), json={ "title": f"flow-test-{suffix}", "db_type": "mysql", "instance_id": test_mysql_instance["id"], "target_database": "test", "sql_content": "SELECT 1", "reason": "Integration test", }) assert resp.status_code == 201 ticket_id = resp.json()["id"] # Get resp = await client.get(f"/api/v1/tickets/{ticket_id}", headers=auth_header(admin_token)) assert resp.status_code == 200 assert resp.json()["id"] == ticket_id async def test_ticket_timeline(self, client: AsyncClient, admin_token: str): lst = await client.get("/api/v1/tickets", headers=auth_header(admin_token)) items = lst.json().get("items", []) if not items: pytest.skip("No tickets") tid = items[0]["id"] resp = await client.get(f"/api/v1/tickets/{tid}/timeline", headers=auth_header(admin_token)) assert resp.status_code == 200