forked from andrew/karung-counting-feedmill-semarang
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
"""Test for input validation module."""
|
|
|
|
|
|
from src.validation import InputValidator, ValidationError
|
|
|
|
|
|
def test_input_validation():
|
|
validator = InputValidator()
|
|
|
|
# Test model path validation - invalid extension (should raise)
|
|
try:
|
|
validator.validate_model_path("/valid/path/model.invalid")
|
|
assert False, "Should have raised ValidationError for invalid extension"
|
|
except ValidationError:
|
|
pass
|
|
|
|
# Test model path validation - empty path (should raise)
|
|
try:
|
|
validator.validate_model_path("")
|
|
assert False, "Should have raised ValidationError for empty path"
|
|
except ValidationError:
|
|
pass
|
|
|
|
# Test video source validation - RTSP URL (valid)
|
|
assert validator.validate_video_source("rtsp://example.com/stream") == True
|
|
|
|
# Test video source validation - HTTP URL (valid)
|
|
assert validator.validate_video_source("http://example.com/stream") == True
|
|
|
|
# Test video source validation - HTTPS URL (valid)
|
|
assert validator.validate_video_source("https://example.com/stream") == True
|
|
|
|
# Test video source validation - RTSP URL with credentials (valid)
|
|
assert validator.validate_video_source("rtsp://admin:secret123@192.168.192.96:554/Streaming/Channels/101") == True
|
|
|
|
# Test video source validation - invalid URL format (should raise)
|
|
try:
|
|
validator.validate_video_source("not-a-valid-source")
|
|
assert False, "Should have raised ValidationError for invalid URL"
|
|
except ValidationError:
|
|
pass
|
|
|