Files

33 lines
1.0 KiB
Python

import uuid
from fastapi.testclient import TestClient
from tests.conftest import bearer, png_bytes, register_and_confirm
def test_my_collections_after_upload(client: TestClient, monkeypatch) -> None:
info = register_and_confirm(
client, monkeypatch,
f"coll-{uuid.uuid4().hex[:8]}@example.com",
"collpass1", "收藏用户",
)
r = client.get("/api/v1/collections/me", headers=bearer(info["token"]))
assert r.status_code == 200
assert len(r.json()) == 0
client.post(
"/api/v1/clouds",
headers=bearer(info["token"]),
files={"image": ("cloud.png", png_bytes(), "image/png")},
data={"cloud_type_id": "1", "is_hidden": "false"},
)
r = client.get("/api/v1/collections/me", headers=bearer(info["token"]))
assert r.status_code == 200
assert len(r.json()) == 1
assert r.json()[0]["cloud_type_id"] == 1
def test_my_collections_unauthenticated(client: TestClient) -> None:
r = client.get("/api/v1/collections/me")
assert r.status_code == 401