feat: add Steam friends and library comparison
CI / test (push) Successful in 37s

Add GET /api/steam/friends and /api/steam/friends/{steamid}, a Friends tab with manual SteamID entry for private profiles, and one-hour caching for friend lists and owned games.
This commit is contained in:
strsv committed 2026-11-07 01:31:44 +03:00
1 parent 5b1b23d392
commit 376a2ee7a0
15 files changed
+456 -15

No files matched your search

+33 -1
View File
@@ -74,9 +74,41 @@ class AchievementTests(unittest.TestCase):
with self.assertRaises(steam_api.SteamApiError) as context:
steam_api._get_json("ISteamUserStats/GetPlayerAchievements/v0001", {"appid": 1})
message = str(context.exception)
self.assertIn("403", message)
self.assertEqual(context.exception.status, 403)
self.assertIn("private", message.lower())
self.assertNotIn("secret-key", message)
class FriendTests(unittest.TestCase):
def setUp(self):
steam_api.clear_cache()
self.addCleanup(steam_api.clear_cache)
def test_friends_and_summaries(self):
def fake(path, params):
if "GetFriendList" in path:
return {"friendslist": {"friends": [{"steamid": "1", "friend_since": 10}]}}
if "GetPlayerSummaries" in path:
return {"response": {"players": [{"steamid": "1", "personaname": "Ann"}]}}
raise AssertionError(path)
with mock.patch.object(steam_api, "_get_json", side_effect=fake) as get:
self.assertEqual(steam_api.friends("765"),
[{"steamid": "1", "friend_since": 10}])
self.assertEqual(steam_api.player_summaries(["1"]),
[{"steamid": "1", "personaname": "Ann"}])
self.assertEqual(get.call_count, 2)
def test_private_friend_list(self):
with mock.patch.object(steam_api, "_get_json", return_value={"friendslist": None}):
self.assertEqual(steam_api.friends("765"), [])
def test_owned_games(self):
with mock.patch.object(
steam_api, "_get_json",
return_value={"response": {"games": [{"appid": 1}]}}):
self.assertEqual(steam_api.owned_games("765"), [{"appid": 1}])
if __name__ == "__main__":
unittest.main()