|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <title>Pyodide Media Module Test</title> |
| 5 | + <link rel="stylesheet" href="../../dist/core.css"> |
| 6 | + <script type="module" src="../../dist/core.js"></script> |
| 7 | +</head> |
| 8 | +<body> |
| 9 | +<h1>Pyodide Media Module Test</h1> |
| 10 | +<div id="test-results">Running tests...</div> |
| 11 | + |
| 12 | +<script type="py" terminal> |
| 13 | + from pyscript import window, document |
| 14 | + from pyscript import media |
| 15 | + |
| 16 | + async def run_tests(): |
| 17 | + # Test basic module structure |
| 18 | + assert hasattr(media, "Device"), "media module should have Device class" |
| 19 | + assert hasattr(media, "list_devices"), "media module should have list_devices function" |
| 20 | + |
| 21 | + # Test device enumeration |
| 22 | + devices = await media.list_devices() |
| 23 | + assert isinstance(devices, list), "list_devices should return a list" |
| 24 | + |
| 25 | + # If we have devices, test properties of one |
| 26 | + if devices: |
| 27 | + device = devices[0] |
| 28 | + assert hasattr(device, "id"), "Device should have id property" |
| 29 | + assert hasattr(device, "group"), "Device should have group property" |
| 30 | + assert hasattr(device, "kind"), "Device should have kind property" |
| 31 | + assert hasattr(device, "label"), "Device should have label property" |
| 32 | + |
| 33 | + document.getElementById('test-results').innerText = "Success!" |
| 34 | + document.documentElement.classList.add('media-ok') |
| 35 | + |
| 36 | + await run_tests() |
| 37 | +</script> |
| 38 | +</body> |
| 39 | +</html> |
0 commit comments