snotes updates, actions, attachments, easy user space

This commit is contained in:
2026-09-22 17:31:55 -07:00
parent ce30c6f4f7
commit abfbf3de1f
21 changed files with 669 additions and 53 deletions

View File

@@ -34,6 +34,49 @@ async def test_users_seeded(client):
names = [u["name"] for u in r.json()]
assert "schmeeve" in names
assert "ilya" in names
assert "common" in names
async def test_create_note_in_common_space(client):
r = await client.post("/api/notes", json={"body": "shared note", "username": "common"})
assert r.status_code == 200
assert r.json()["username"] == "common"
async def test_move_note_between_spaces(client):
r = await client.post("/api/notes", json={"body": "start here"})
note_id = r.json()["id"]
assert r.json()["username"] == "schmeeve"
r2 = await client.put(f"/api/notes/{note_id}", json={"body": "moved", "username": "common"})
assert r2.status_code == 200
assert r2.json()["username"] == "common"
async def test_create_note_unknown_space(client):
r = await client.post("/api/notes", json={"body": "x", "username": "ghost"})
assert r.status_code == 404
async def test_upload_and_serve_attachment(client):
r = await client.post(
"/api/attachments",
files={"file": ("photo.png", b"fakeimage", "image/png")},
data={"username": "common"},
)
assert r.status_code == 200
data = r.json()
assert data["url"].startswith("/api/attachments/common/")
assert data["path"] == f"common/attachments/{data['url'].rsplit('/', 1)[-1]}"
r2 = await client.get(data["url"])
assert r2.status_code == 200
assert r2.content == b"fakeimage"
async def test_attachment_not_found(client):
r = await client.get("/api/attachments/common/does-not-exist.png")
assert r.status_code == 404
async def test_create_and_get_note(client):