- Label + NoteLabel models; migration 0004 (labels unique per owner + note_labels join, cascade). - /api/labels: list/create(idempotent)/rename(clash-checked)/delete, owner-scoped. - PUT /api/notes/<id>/labels to set a note's labels (validated against owned). - Note responses now include labels[] (merged via one explicit join query — no lazy relationship); GET /api/notes?...&label=<id> filters by label. - DB-free auth-guard tests for labels endpoints. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
24 lines
512 B
Python
24 lines
512 B
Python
import pytest
|
|
|
|
from thoughtsync.app import create_app
|
|
|
|
|
|
@pytest.fixture
|
|
def app():
|
|
return create_app()
|
|
|
|
|
|
async def test_labels_requires_auth(app):
|
|
client = app.test_client()
|
|
resp = await client.get("/api/labels")
|
|
assert resp.status_code == 401
|
|
|
|
|
|
async def test_set_note_labels_requires_auth(app):
|
|
client = app.test_client()
|
|
resp = await client.put(
|
|
"/api/notes/00000000-0000-0000-0000-000000000000/labels",
|
|
json={"label_ids": []},
|
|
)
|
|
assert resp.status_code == 401
|