phase 10
This commit is contained in:
67
tests/detect/test_replay.py
Normal file
67
tests/detect/test_replay.py
Normal file
@@ -0,0 +1,67 @@
|
||||
"""Tests for replay and OverrideProfile."""
|
||||
|
||||
import pytest
|
||||
|
||||
from detect.profiles.soccer import SoccerBroadcastProfile
|
||||
from detect.checkpoint.replay import OverrideProfile
|
||||
|
||||
|
||||
def test_override_profile_patches_ocr():
|
||||
base = SoccerBroadcastProfile()
|
||||
overrides = {"ocr": {"min_confidence": 0.3, "languages": ["en", "es", "pt"]}}
|
||||
profile = OverrideProfile(base, overrides)
|
||||
|
||||
config = profile.ocr_config()
|
||||
|
||||
assert config.min_confidence == 0.3
|
||||
assert config.languages == ["en", "es", "pt"]
|
||||
|
||||
|
||||
def test_override_profile_patches_resolver():
|
||||
base = SoccerBroadcastProfile()
|
||||
overrides = {"resolver": {"fuzzy_threshold": 60}}
|
||||
profile = OverrideProfile(base, overrides)
|
||||
|
||||
config = profile.resolver_config()
|
||||
|
||||
assert config.fuzzy_threshold == 60
|
||||
|
||||
|
||||
def test_override_profile_patches_detection():
|
||||
base = SoccerBroadcastProfile()
|
||||
overrides = {"detection": {"confidence_threshold": 0.5}}
|
||||
profile = OverrideProfile(base, overrides)
|
||||
|
||||
config = profile.detection_config()
|
||||
|
||||
assert config.confidence_threshold == 0.5
|
||||
|
||||
|
||||
def test_override_profile_no_overrides():
|
||||
base = SoccerBroadcastProfile()
|
||||
profile = OverrideProfile(base, {})
|
||||
|
||||
ocr = profile.ocr_config()
|
||||
base_ocr = base.ocr_config()
|
||||
|
||||
assert ocr.min_confidence == base_ocr.min_confidence
|
||||
assert ocr.languages == base_ocr.languages
|
||||
|
||||
|
||||
def test_override_profile_delegates_non_config():
|
||||
base = SoccerBroadcastProfile()
|
||||
profile = OverrideProfile(base, {"ocr": {"min_confidence": 0.1}})
|
||||
|
||||
assert profile.name == "soccer_broadcast"
|
||||
assert profile.resolver_config().fuzzy_threshold > 0
|
||||
|
||||
|
||||
def test_override_profile_ignores_unknown_fields():
|
||||
base = SoccerBroadcastProfile()
|
||||
overrides = {"ocr": {"nonexistent_field": 42}}
|
||||
profile = OverrideProfile(base, overrides)
|
||||
|
||||
config = profile.ocr_config()
|
||||
|
||||
assert not hasattr(config, "nonexistent_field")
|
||||
assert config.min_confidence == base.ocr_config().min_confidence
|
||||
Reference in New Issue
Block a user