"""Example feature tests exercising the in-memory notes API."""

from __future__ import annotations

from fastapi.testclient import TestClient

from src.main import app

client = TestClient(app)


def test_create_and_list_notes() -> None:
    payload = {"title": "First note", "body": "Documented via RapidKit."}
    create_response = client.post("/api/examples/notes", json=payload)
    assert create_response.status_code == 201
    data = create_response.json()
    assert data["title"] == payload["title"]
    assert data["body"] == payload["body"]

    list_response = client.get("/api/examples/notes")
    assert list_response.status_code == 200
    notes = list_response.json()
    assert any(note["title"] == payload["title"] for note in notes)


def test_get_missing_note_returns_404() -> None:
    response = client.get("/api/examples/notes/999")
    assert response.status_code == 404
    assert response.json()["detail"] == "Note not found"
