mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-11 21:18:35 +03:00
introduces user.read_public drops unused endpoints
This commit is contained in:
@@ -83,62 +83,6 @@ def test_search_by_url(client_with_auth, db_session):
|
||||
assert len(response.json()) == 10
|
||||
|
||||
|
||||
def test_latest_unauthenticated(client, test_no_auth):
|
||||
test_no_auth(client.get, "/url/latest")
|
||||
|
||||
|
||||
def test_latest(client_with_auth, db_session):
|
||||
response = client_with_auth.get("/url/latest")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == []
|
||||
|
||||
from db import crud, schemas
|
||||
for i in range(11):
|
||||
crud.create_task(db_session, ArchiveCreate(id=f"latest-456-{i}", url="https://example.com", result={}, public=True, author_id="morty@example.com" if i < 10 else "rick@example.com", group_id=None), [], [])
|
||||
#NB: this insertion is too fast for the ordering to be correct as they are within the same second
|
||||
|
||||
# user must exist for /latest to work
|
||||
crud.create_or_get_user(db_session, "morty@example.com")
|
||||
|
||||
response = client_with_auth.get("/url/latest")
|
||||
assert response.status_code == 200
|
||||
assert len(j := response.json()) == 10
|
||||
assert "latest-456-0" in [i["id"] for i in j]
|
||||
assert "latest-456-9" in [i["id"] for i in j]
|
||||
assert "latest-456-10" not in [i["id"] for i in j]
|
||||
assert j[0].keys() == schemas.ArchiveResult.model_fields.keys()
|
||||
|
||||
response = client_with_auth.get("/url/latest?limit=5")
|
||||
assert response.status_code == 200
|
||||
assert len(response.json()) == 5
|
||||
|
||||
response = client_with_auth.get("/url/latest?skip=5&limit=2")
|
||||
assert response.status_code == 200
|
||||
assert len(response.json()) == 2
|
||||
|
||||
|
||||
# # TODO: find out where/if this is used, tests are also disabled
|
||||
|
||||
# def test_lookup_unauthenticated(client, test_no_auth):
|
||||
# test_no_auth(client.get, "/url/123-456-789")
|
||||
|
||||
# def test_lookup(client_with_auth, db_session):
|
||||
# response = client_with_auth.get("/url/lookup-123-456-789")
|
||||
# assert response.status_code == 404
|
||||
# assert response.json() == {"detail": "Archive not found"}
|
||||
|
||||
# from db import crud, schemas
|
||||
# crud.create_task(db_session, ArchiveCreate(id="lookup-123-456-789", url="https://example.com", result={}, public=True, author_id="rick@example.com", group_id=None), [], [])
|
||||
|
||||
# response = client_with_auth.get("/url/lookup-123-456-789")
|
||||
# assert response.status_code == 200
|
||||
# j = response.json()
|
||||
# assert j.keys() == schemas.ArchiveResult.model_fields.keys()
|
||||
# assert j["id"] == "lookup-123-456-789"
|
||||
# assert j["url"] == "https://example.com"
|
||||
# assert j["result"] == {}
|
||||
|
||||
|
||||
def test_delete_task_unauthenticated(client, test_no_auth):
|
||||
test_no_auth(client.delete, "/url/123-456-789")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user