api: dedup ghost history rows (int vs string ep_id); normalize ep_id on write
This commit is contained in:
1 parent
8f57593002
commit
d39ee838ff
2 files changed
+32
-4
No files matched your search
+15
-2
@@ -111,8 +111,9 @@ def test_history_per_user(base=BASE):
|
||||
assert req("POST", "/api/history", entry, jar=a, base=base) == 200
|
||||
got_a = _json("GET", "/api/history", jar=a, base=base)
|
||||
got_b = _json("GET", "/api/history", jar=b, base=base)
|
||||
assert any(e["ep_id"] == "111" for e in got_a)
|
||||
assert all(e.get("ep_id") != "111" for e in got_b), "leak: admin entry in alice's history"
|
||||
# ep_id is normalized to int on write (ghost-row fix)
|
||||
assert any(e["ep_id"] == 111 for e in got_a)
|
||||
assert all(e.get("ep_id") != 111 for e in got_b), "leak: admin entry in alice's history"
|
||||
|
||||
|
||||
def test_history_all_and_delete(base=BASE):
|
||||
@@ -138,6 +139,18 @@ def test_history_all_and_delete(base=BASE):
|
||||
jar=jar, base=base)["removed"] == 0
|
||||
|
||||
|
||||
def test_history_no_ghost_duplicates(base=BASE):
|
||||
"""same episode posted with int and string ep_id -> exactly one row"""
|
||||
jar = login("alice", "alicepw12345", base)
|
||||
for ep in (301, "301"):
|
||||
assert req("POST", "/api/history",
|
||||
{"ep_id": ep, "slug_id": "ghost-a", "title": "Ghost", "season_id": 1,
|
||||
"ep": "1", "lang": "eng", "pos": 5}, jar=jar, base=base) == 200
|
||||
rows = [e for e in _json("GET", "/api/history?all=1", jar=jar, base=base)
|
||||
if e["slug_id"] == "ghost-a"]
|
||||
assert len(rows) == 1 and rows[0]["ep_id"] == 301, rows
|
||||
|
||||
|
||||
def test_recent_searches(base=BASE):
|
||||
a = login("alice", "alicepw12345", base)
|
||||
assert req("POST", "/api/searches", {"q": "naruto"}, jar=a, base=base) == 200
|
||||
|
||||
Reference in new issue
Block a user