refactor(api)!: remove the standalone API server (#6614)
This commit is contained in:
1 parent
5c72ced2fe
commit
220d5e6970
99 files changed
+240
-4133
No files matched your search
@@ -6,9 +6,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from nanobot.utils.media_decode import (
|
||||
DEFAULT_MAX_BYTES,
|
||||
MAX_FILE_SIZE,
|
||||
FileSizeExceeded,
|
||||
FileSizeExceededError,
|
||||
save_base64_data_url,
|
||||
)
|
||||
|
||||
@@ -134,19 +132,15 @@ def test_unknown_mime_falls_back_to_bin(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_default_limit_is_10mb(tmp_path) -> None:
|
||||
assert DEFAULT_MAX_BYTES == 10 * 1024 * 1024
|
||||
assert MAX_FILE_SIZE == 10 * 1024 * 1024
|
||||
|
||||
oversized = b"x" * (11 * 1024 * 1024)
|
||||
with pytest.raises(FileSizeExceeded, match="10MB limit"):
|
||||
oversized = b"x" * (10 * 1024 * 1024 + 1)
|
||||
with pytest.raises(FileSizeExceededError, match="10MB limit"):
|
||||
save_base64_data_url(_data_url(oversized), tmp_path)
|
||||
|
||||
|
||||
def test_explicit_max_bytes_overrides_default(tmp_path) -> None:
|
||||
"""WS channel passes 8 MB; a 9 MB payload should be rejected there even
|
||||
though it would pass the 10 MB API limit."""
|
||||
"""The caller can reject a payload smaller than the default limit."""
|
||||
payload = b"y" * (9 * 1024 * 1024)
|
||||
with pytest.raises(FileSizeExceeded, match="8MB limit"):
|
||||
with pytest.raises(FileSizeExceededError, match="8MB limit"):
|
||||
save_base64_data_url(_data_url(payload), tmp_path, max_bytes=8 * 1024 * 1024)
|
||||
|
||||
|
||||
@@ -154,13 +148,3 @@ def test_saved_file_lives_under_media_dir(tmp_path) -> None:
|
||||
result = save_base64_data_url(_data_url(b"ok"), tmp_path)
|
||||
assert result is not None
|
||||
assert result.startswith(str(tmp_path))
|
||||
|
||||
|
||||
def test_legacy_symbols_reexported_from_api_server() -> None:
|
||||
"""Existing tests import ``_save_base64_data_url`` / ``_FileSizeExceeded``
|
||||
from ``nanobot.api.server`` — keep the aliases working."""
|
||||
from nanobot.api import server
|
||||
|
||||
assert server._save_base64_data_url is save_base64_data_url
|
||||
assert server._FileSizeExceeded is FileSizeExceeded
|
||||
assert server.MAX_FILE_SIZE == MAX_FILE_SIZE
|
||||
Reference in new issue
Block a user