feat: add bulk actions for selected games
CI / test (push) Successful in 19s

This commit is contained in:
strsv committed 2026-11-06 08:51:31 +03:00
1 parent 17e5805b2e
commit c811107776
11 files changed
+253 -12

No files matched your search

+29
View File
@@ -306,6 +306,35 @@ class ApiTests(unittest.TestCase):
finally:
con.close()
def test_personal_bulk_update(self):
try:
data = self.post("/api/personal/bulk", {
"appids": [1, 1, 2], "status": "ignore", "favorite": True})
self.assertEqual(data["updated"], 2)
for appid in (1, 2):
item = self.get(f"/api/game/{appid}")
self.assertEqual(item["status"], "ignore")
self.assertTrue(item["favorite"])
self.assertEqual(self.get("/api/game/1")["rating"], 9)
self.assertEqual(self.get("/api/game/1")["notes"], "заметка")
self.assertEqual(self.post("/api/personal/bulk", {"appids": []}, expect=400)["error"],
"no appids")
self.assertEqual(self.post("/api/personal/bulk", {"appids": [1]}, expect=400)["error"],
"nothing to update")
self.assertEqual(self.post("/api/personal/bulk", {"appids": [999], "status": "played"},
expect=404)["error"], "unknown appids")
finally:
con = db.connect(self.db_path)
try:
con.execute("""UPDATE personal SET status='playing', rating=9, favorite=1,
notes='заметка' WHERE appid=1""")
con.execute("""UPDATE personal SET status='backlog', rating=NULL, favorite=0,
notes=NULL WHERE appid=2""")
con.commit()
finally:
con.close()
def test_personal_errors(self):
self.assertEqual(self.post("/api/personal/999", {"rating": 5}, expect=404)["error"],
"unknown appid")