Files
arc53--docsgpt/tests/stt/test_upload_limits.py
wehub-resource-sync fed8b2eed7
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:28:29 +08:00

40 lines
1.2 KiB
Python

from unittest.mock import patch
from application.stt.upload_limits import (
build_stt_file_size_limit_message,
enforce_audio_file_size_limit,
is_audio_filename,
should_reject_stt_request,
)
@patch("application.stt.upload_limits.settings")
def test_should_reject_stt_request_when_content_length_exceeds_limit(mock_settings):
mock_settings.STT_MAX_FILE_SIZE_MB = 1
assert (
should_reject_stt_request(
"/api/stt",
(2 * 1024 * 1024) + 1,
)
is True
)
assert should_reject_stt_request("/api/upload", (2 * 1024 * 1024) + 1) is False
@patch("application.stt.upload_limits.settings")
def test_enforce_audio_file_size_limit_uses_configured_message(mock_settings):
mock_settings.STT_MAX_FILE_SIZE_MB = 1
try:
enforce_audio_file_size_limit(2 * 1024 * 1024)
except ValueError as exc:
assert str(exc) == build_stt_file_size_limit_message()
else:
raise AssertionError("Expected oversized audio file to raise")
def test_is_audio_filename_handles_supported_extensions():
assert is_audio_filename("meeting.wav") is True
assert is_audio_filename("meeting.txt") is False