aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-26 11:16:40 +0100
committerDanilo M. <danix@danix.xyz>2026-11-26 11:16:40 +0100
commitd842b3c49fe4c03993f32fb9bebbef954c54675d (patch)
treee88f36e59793104cf220642ad792ca8df3a9a392 /tests
parent6496d0660abf781ff2a76f97f9a5c03034d6cf45 (diff)
downloaddeck-it-d842b3c49fe4c03993f32fb9bebbef954c54675d.tar.gz
deck-it-d842b3c49fe4c03993f32fb9bebbef954c54675d.zip
feat(xbox): list, view and download uploaded captures
The slow read also searches mediahub for the user's screenshots and game clips. Their CDN URIs are signed, so the tab shows thumbnails and opens a capture in a dialog (outside the redrawn part, so a data change leaves it open) with a download link and a close button, straight from Microsoft. Only captures the console uploaded appear; an in-game photo mode (e.g. Rockstar's) is not an Xbox capture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xbox.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_xbox.py b/tests/test_xbox.py
index 0bcc883..a05ba60 100644
--- a/tests/test_xbox.py
+++ b/tests/test_xbox.py
@@ -63,6 +63,13 @@ FRIENDS = {"people": [
{"gamertag": "zed", "displayPicRaw": "z.png", "presenceState": "Offline", "presenceText": "Offline", "isFavorite": True},
{"gamertag": "bob", "displayPicRaw": "b.png", "presenceState": "Online", "presenceText": "Some Game", "isFavorite": False},
{"gamertag": "amy", "displayPicRaw": "a.png", "presenceState": "Online", "presenceText": "Home", "isFavorite": True}]}
+SHOTS = {"values": [{"contentId": "S1", "titleName": "Some Game", "captureDate": "2026-11-22T14:08:54Z",
+ "expirationDate": "2027-02-20T14:09:07Z", "contentLocators": [
+ {"locatorType": "Download", "uri": "https://cdn.example.org/s1.png?sig=x"},
+ {"locatorType": "Thumbnail_Large", "uri": "https://cdn.example.org/s1_t.png"}]}]}
+CLIPS = {"values": [{"contentId": "C1", "titleName": "Some Game", "captureDate": "2026-11-23T10:00:00Z",
+ "durationInSeconds": 30, "contentLocators": [{"locatorType": "Download", "uri": "https://cdn.example.org/c1.mp4"}]},
+ {"contentId": "C2", "contentLocators": []}]}
XSTS = {"Token": "XT", "DisplayClaims": {"xui": [{"uhs": "UHS", "xid": "1"}]}}
@@ -90,6 +97,8 @@ class Fake:
"/commands": {"status": {"errorCode": "OK"}, "opId": "op"},
"/lists/installedApps": APPS,
"/titles/batch/": BATCH,
+ "mediahub.xboxlive.com/screenshots": SHOTS,
+ "mediahub.xboxlive.com/gameclips": CLIPS,
}
self.answers.update(over)
@@ -212,6 +221,13 @@ class Summaries(unittest.TestCase):
def test_friends_online_then_favourite_then_name(self):
self.assertEqual([f["gamertag"] for f in xb.summarize_friends(FRIENDS)], ["amy", "bob", "zed"])
+ def test_captures_newest_first_without_a_download_skipped(self):
+ c = xb.summarize_captures(SHOTS, CLIPS)
+ self.assertEqual([(x["id"], x["kind"]) for x in c], [("C1", "clip"), ("S1", "shot")])
+ self.assertEqual((c[1]["thumb"], c[1]["url"]),
+ ("https://cdn.example.org/s1_t.png", "https://cdn.example.org/s1.png?sig=x"))
+ self.assertEqual(c[0]["seconds"], 30)
+
class Login(Base):
def test_no_client_id_refuses(self):
@@ -269,6 +285,8 @@ 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(len(st["captures"]), 2)
+ self.assertEqual(self.fake.urls("mediahub")[0][1]["query"], "OwnerXuid eq 1")
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"])