feat: compare recommendations across presets
CI / test (push) Successful in 5m14s

This commit is contained in:
strsv committed 2026-11-06 21:18:55 +03:00
1 parent fbdbe59150
commit ef749e935b
9 files changed
+141 -8

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
"""Tests for preset comparison."""
import os
import sys
import unittest
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(ROOT, "tools"))
import compare_presets
class CompareTests(unittest.TestCase):
def game(self, appid):
return {"appid": appid, "name": f"Game {appid}", "score": 1.0}
def test_compare_lists(self):
result = compare_presets.compare_lists(
[self.game(1), self.game(2), self.game(3)],
[self.game(2), self.game(3), self.game(4)])
self.assertEqual(result["common"], [2, 3])
self.assertEqual(result["only_a"], [1])
self.assertEqual(result["only_b"], [4])
self.assertEqual(result["jaccard"], 0.5)
def test_empty(self):
result = compare_presets.compare_lists([], [])
self.assertEqual(result["jaccard"], 0.0)
self.assertEqual(result["common"], [])
if __name__ == "__main__":
unittest.main()