Add media module tests (#2306)

* Add media Python tests

* Add media js test

* Remove try except blocks

* Make Python tests more end-to-end

* Add media Python tests

* Add media js test

* Remove try except blocks

* Make Python tests more end-to-end

* MicroPython explorations.

* Fix websocket tests, so they just skip.

* Fix MicroPython media tests, if no permission is given for a video device.

---------

Co-authored-by: Nicholas H.Tollervey <ntoll@ntoll.org>
Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
This commit is contained in:
Dan Yeaw
2025-03-20 09:35:01 -04:00
committed by GitHub
parent 46ca9154c4
commit b911ea99fb
8 changed files with 162 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@@ -31,25 +31,22 @@ class Device:
@classmethod
async def load(cls, audio=False, video=True):
"""Load the device stream."""
options = window.Object.new()
options.audio = audio
"""
Load the device stream.
"""
options = {}
options["audio"] = audio
if isinstance(video, bool):
options.video = video
options["video"] = video
else:
# TODO: Think this can be simplified but need to check it on the pyodide side
# TODO: this is pyodide specific. shouldn't be!
options.video = window.Object.new()
options["video"] = {}
for k in video:
setattr(options.video, k, to_js(video[k]))
return await window.navigator.mediaDevices.getUserMedia(options)
options["video"][k] = video[k]
return await window.navigator.mediaDevices.getUserMedia(to_js(options))
async def get_stream(self):
key = self.kind.replace("input", "").replace("output", "")
options = {key: {"deviceId": {"exact": self.id}}}
return await self.load(**options)