Download tests/test_camera.py from drowzeys/keys-Auto-Receipts-Studio: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/drowzeys/keys-Auto-Receipts-Studio/resolve/main/tests/test_camera.py
- Command line
-
hf download hf://drowzeys/keys-Auto-Receipts-Studio/tests/test_camera.py
-
curl -L -o test_camera.py https://huggingface.co/drowzeys/keys-Auto-Receipts-Studio/resolve/main/tests/test_camera.py
1.25 kB
| from __future__ import annotations | |
| from pathlib import Path | |
| import httpx | |
| from app.camera import aim, snapshot | |
| from app.config import Settings | |
| def test_snapshot_reads_path(settings: Settings, tmp_path: Path) -> None: | |
| saved = tmp_path / "snap.jpg" | |
| saved.write_bytes(b"x") | |
| def handler(request: httpx.Request) -> httpx.Response: | |
| assert "width=1280" in str(request.url) | |
| return httpx.Response(200, json={"path": str(saved)}) | |
| client = httpx.Client(transport=httpx.MockTransport(handler), base_url="http://hal.test") | |
| settings = settings.model_copy(update={"camera_url": "http://hal.test"}) | |
| assert snapshot(settings, client=client) == saved | |
| def test_aim_posts_direction(settings: Settings) -> None: | |
| seen: list[str] = [] | |
| def handler(request: httpx.Request) -> httpx.Response: | |
| seen.append(request.method + " " + str(request.url)) | |
| assert b"down" in request.content | |
| return httpx.Response(200, json={"ok": True}) | |
| client = httpx.Client(transport=httpx.MockTransport(handler), base_url="http://hal.test") | |
| settings = settings.model_copy(update={"camera_url": "http://hal.test"}) | |
| aim(settings, "down", client=client) | |
| assert any("servo/aim" in url for url in seen) | |