1 parent
f25d218756
commit
044d0279b3
17 files changed
+288
-20
No files matched your search
@@ -146,6 +146,31 @@ class RecommendTests(RecoFixture):
|
||||
_, results = reco.recommend(self.con, self.mood(), limit=2)
|
||||
self.assertEqual(len(results), 2)
|
||||
|
||||
def test_feedback_excludes_and_boosts(self):
|
||||
key = "preset:test"
|
||||
_, base = reco.recommend(self.con, self.mood(), limit=10)
|
||||
base_alpha = next(g for g in base if g["appid"] == 1)
|
||||
|
||||
self.con.executemany(
|
||||
"INSERT INTO reco_feedback (appid, mood_key, verdict, created_at) VALUES (?,?,?,?)",
|
||||
[(1, key, "like", "2026-01-01"),
|
||||
(2, key, "dislike", "2026-01-01"),
|
||||
(4, key, "played", "2026-01-01")])
|
||||
self.con.commit()
|
||||
try:
|
||||
_, results = reco.recommend(self.con, self.mood(), limit=10, feedback_key=key)
|
||||
ids = [g["appid"] for g in results]
|
||||
self.assertNotIn(2, ids)
|
||||
self.assertNotIn(4, ids)
|
||||
self.assertIn(1, ids)
|
||||
alpha = next(g for g in results if g["appid"] == 1)
|
||||
self.assertEqual(alpha["feedback"], "like")
|
||||
self.assertGreater(alpha["score"], base_alpha["score"])
|
||||
self.assertIsNone(next(g for g in results if g["appid"] == 3)["feedback"])
|
||||
finally:
|
||||
self.con.execute("DELETE FROM reco_feedback WHERE mood_key = ?", (key,))
|
||||
self.con.commit()
|
||||
|
||||
def test_no_eligible_games(self):
|
||||
mood, results = reco.recommend(self.con, self.mood(), allowed_statuses=["tribute"])
|
||||
self.assertEqual(mood["description"], "test")
|
||||
|
||||
Reference in new issue
Block a user