feat(requests): add bulk update, bulk delete and a count endpoint
This commit is contained in:
1 parent
f7f89a3cc7
commit
07c988c443
2 files changed
+70
-1
No files matched your search
@@ -1270,3 +1270,27 @@ def test_connections_hear_about_committed_rows(client, monkeypatch):
|
||||
calls.clear()
|
||||
client.delete(f"/api/requests/{req_id}")
|
||||
assert calls == [("POST", "http://hook/in")] # nothing new on disk, no scan
|
||||
|
||||
|
||||
def test_bulk_move_delete_and_count(client):
|
||||
def lib(name, media_type):
|
||||
return client.post("/api/libraries", json={
|
||||
"name": name, "media_type": media_type,
|
||||
"root_path": str(client.tmp_path / name)}).json()["id"]
|
||||
|
||||
a, b, audio = lib("a", "ebook"), lib("b", "ebook"), lib("audio", "audiobook")
|
||||
ids = [client.post("/api/requests", json={"library_id": a, "title": f"T{i}"}).json()["id"]
|
||||
for i in range(3)]
|
||||
assert client.get("/api/requests/count?status=missing").json() == {"count": 3}
|
||||
|
||||
assert client.put("/api/requests/bulk", json={
|
||||
"ids": ids[:2], "library_id": audio}).status_code == 400
|
||||
assert client.put("/api/requests/bulk", json={
|
||||
"ids": ids[:2], "library_id": b}).json() == {"updated": 2}
|
||||
assert [r["id"] for r in client.get(f"/api/requests?library_id={b}").json()] \
|
||||
== sorted(ids[:2], reverse=True)
|
||||
|
||||
assert client.request("DELETE", "/api/requests/bulk",
|
||||
json={"ids": ids[1:]}).json() == {"deleted": 2}
|
||||
assert client.get("/api/requests/count?status=missing").json() == {"count": 1}
|
||||
assert [r["event"] for r in client.get("/api/history").json()] == ["deleted"] * 2
|
||||
Reference in new issue
Block a user