import uuid import pytest from thoughtsync.app import create_app from thoughtsync.models.label import Label from thoughtsync.serialize import serialize_label @pytest.fixture def app(): return create_app() def test_serialize_label_shape(): # The base {id, name, color} shape the labels API and (S4) sync deltas both build on. lid = uuid.uuid4() assert serialize_label(Label(id=lid, name="ideas", color="teal")) == { "id": str(lid), "name": "ideas", "color": "teal", } 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 async def test_merge_label_requires_auth(app): client = app.test_client() resp = await client.post( "/api/labels/00000000-0000-0000-0000-000000000000/merge", json={"into": "00000000-0000-0000-0000-000000000001"}, ) assert resp.status_code == 401