Spaces:
Runtime error
Runtime error
Download backend/tests/storage/test_in_memory.py from Talosware/talos-access: direct link, hf CLI and curl.
- Browser
- Download file 938 Bytes
-
https://huggingface.co/spaces/Talosware/talos-access/resolve/main/backend/tests/storage/test_in_memory.py
- Command line
-
hf download hf://spaces/Talosware/talos-access/backend/tests/storage/test_in_memory.py
-
curl -L -o test_in_memory.py https://huggingface.co/spaces/Talosware/talos-access/resolve/main/backend/tests/storage/test_in_memory.py
938 Bytes
| import pytest | |
| from app.storage.in_memory import InMemoryStorage | |
| def test_upload_returns_unique_path(): | |
| storage = InMemoryStorage() | |
| p1 = storage.upload(account_id=1, user_id=10, content=b"a", ext="webp") | |
| p2 = storage.upload(account_id=1, user_id=10, content=b"a", ext="webp") | |
| assert p1 != p2 | |
| assert p1.startswith("mem://1/10/") and p1.endswith(".webp") | |
| def test_get_url_returns_canonical_form(): | |
| storage = InMemoryStorage() | |
| path = storage.upload(1, 10, b"x", "webp") | |
| assert storage.get_url(path) == path | |
| def test_delete_is_idempotent(): | |
| storage = InMemoryStorage() | |
| path = storage.upload(1, 10, b"x", "webp") | |
| storage.delete(path) | |
| storage.delete(path) | |
| storage.delete("mem://does/not/exist.webp") | |
| def test_files_attribute_exposes_content_for_assertions(): | |
| storage = InMemoryStorage() | |
| path = storage.upload(1, 10, b"hello", "webp") | |
| assert storage.files[path] == b"hello" | |