aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_xbox.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-16 17:44:47 +0100
committerDanilo M. <danix@danix.xyz>2026-11-16 17:44:47 +0100
commita81ad9738e9013557b2bd3cbdd7014d981f032fe (patch)
treeebe846a59dbc99f22ff2e021c293f39e24764bb2 /tests/test_xbox.py
parentdf7b5062118467dc02d3baade9a6b74390c050ba (diff)
downloaddeck-it-a81ad9738e9013557b2bd3cbdd7014d981f032fe.tar.gz
deck-it-a81ad9738e9013557b2bd3cbdd7014d981f032fe.zip
feat(xbox): one games list with installed badges
Diffstat (limited to 'tests/test_xbox.py')
-rw-r--r--tests/test_xbox.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/tests/test_xbox.py b/tests/test_xbox.py
index f70aa6f..8844e3b 100644
--- a/tests/test_xbox.py
+++ b/tests/test_xbox.py
@@ -37,9 +37,17 @@ PROFILE = {"profileUsers": [{"id": "1", "settings": [
{"id": "Gamertag", "value": "Player"}, {"id": "GameDisplayPicRaw", "value": "https://img.example.org/p.png"},
{"id": "Gamerscore", "value": "12345"}]}]}
APPS = {"result": [
- {"name": "Small App", "contentType": "App", "sizeInBytes": 1e8, "version": 7, "installTime": "2026-10-01T00:00:00Z"},
- {"name": "Big Game", "contentType": "Game", "sizeInBytes": 9e10, "version": 12, "installTime": "2026-09-01T00:00:00Z",
- "updateTime": "2026-11-10T00:00:00Z", "lastActiveTime": "2026-11-15T21:00:00Z"}]}
+ {"titleId": 99, "aumid": "Video.App_x!App", "name": "Video App", "contentType": "App", "sizeInBytes": 1e8,
+ "version": 7, "installTime": "2026-10-01T00:00:00Z"},
+ {"titleId": 1234, "aumid": "Some.Game_x!Game", "name": "Some Game", "contentType": "Game", "sizeInBytes": 9e10,
+ "version": 12, "installTime": "2026-09-01T00:00:00Z", "updateTime": "2026-11-10T00:00:00Z",
+ "lastActiveTime": "2026-11-15T21:00:00Z"},
+ {"titleId": 777, "aumid": "Old.Game_x!Game", "name": "Old Game", "contentType": "Game", "sizeInBytes": 5e10,
+ "version": 3, "installTime": "2026-01-01T00:00:00Z", "lastActiveTime": "2026-03-01T00:00:00Z"},
+ {"name": "Some Game Expansion", "contentType": "Dlc", "sizeInBytes": 2e9}]}
+BATCH = {"titles": [{"titleId": "777", "pfn": "Old.Game_x", "name": "Old Game", "type": "Game",
+ "displayImage": "https://img.example.org/o.png",
+ "achievement": {"currentGamerscore": 50, "totalGamerscore": 1000, "progressPercentage": 5.0}}]}
HISTORY = {"titles": [
{"titleId": "1234", "name": "Some Game", "type": "Game", "displayImage": "https://img.example.org/c.png",
"titleHistory": {"lastTimePlayed": "2026-11-16T10:00:00Z"},
@@ -81,6 +89,7 @@ class Fake:
"peoplehub": FRIENDS,
"/commands": {"status": {"errorCode": "OK"}, "opId": "op"},
"/lists/installedApps": APPS,
+ "/titles/batch/": BATCH,
}
self.answers.update(over)
@@ -172,11 +181,20 @@ class Summaries(unittest.TestCase):
self.assertEqual((c["id"], c["name"], c["power"]), ("CON1", "Living room", "On"))
self.assertEqual(c["storage"], [{"name": "Internal", "free": 4e11, "total": 1e12}])
- def test_apps_biggest_first(self):
+ def test_apps_skip_dlc(self):
a = xb.summarize_apps(APPS)
- self.assertEqual([x["name"] for x in a], ["Big Game", "Small App"])
- self.assertEqual((a[0]["game"], a[0]["version"], a[0]["updated"]), (True, 12, "2026-11-10T00:00:00Z"))
- self.assertEqual(a[1]["updated"], "2026-10-01T00:00:00Z") # never updated: the install time
+ self.assertEqual([x["name"] for x in a], ["Video App", "Some Game", "Old Game"])
+ self.assertEqual((a[1]["id"], a[1]["pfn"], a[1]["updated"]), ("1234", "Some.Game_x", "2026-11-10T00:00:00Z"))
+ self.assertEqual(a[0]["updated"], "2026-10-01T00:00:00Z") # never updated: the install time
+
+ def test_merge_marks_installed_and_sorts_by_last_played(self):
+ titles = xb.summarize_titles(HISTORY, {}) + xb.summarize_titles(BATCH, {})
+ merged = xb.merge_installed(titles, {"CON1": xb.summarize_apps(APPS)})
+ self.assertEqual([t["name"] for t in merged], ["Some Game", "Old Game", "Video App"])
+ self.assertEqual(merged[0]["installed"]["size"], 9e10)
+ self.assertEqual(merged[0]["last"], "2026-11-16T10:00:00Z") # the newer of history and console
+ self.assertEqual(merged[1]["last"], "2026-03-01T00:00:00Z") # no history: the console's last use
+ self.assertEqual(merged[1]["installed"]["version"], 3)
def test_minutes_and_titles(self):
minutes = xb.minutes_played(STATS)
@@ -251,8 +269,11 @@ class Tick(Base):
self.assertEqual(st["titles"][0]["minutes"], 185)
self.assertEqual(st["achievements"][0]["score"], 15)
self.assertEqual(st["friends"][0]["gamertag"], "amy")
- self.assertEqual(st["apps"]["CON1"][0]["name"], "Big Game")
self.assertIn("deviceId=CON1", self.fake.urls("/lists/installedApps")[0][0])
+ # the installed game missing from the recent ones comes from the batch, by pfn
+ self.assertEqual(self.fake.urls("/titles/batch/")[0][1]["pfns"], ["Old.Game_x"])
+ old = next(t for t in st["titles"] if t["name"] == "Old Game")
+ self.assertEqual((old["cover"], old["installed"]["size"]), ("https://img.example.org/o.png", 5e10))
self.assertEqual(st["playing"]["name"], "Some Game")
self.assertIsInstance(st["session"], int)
self.assertEqual(self.status.read_text(), "1")