-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_config.py
More file actions
60 lines (41 loc) · 1.62 KB
/
test_config.py
File metadata and controls
60 lines (41 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Tests for configuration module."""
from pathlib import Path
import pytest
from pydantic import ValidationError
from emotion_recognition.config import Settings, get_settings
def test_settings_default_values() -> None:
"""Test that settings have correct default values."""
settings = Settings()
assert settings.app_name == "Emotion Recognition System"
assert settings.app_version == "2.0.0"
assert settings.debug is False
assert settings.log_level == "INFO"
def test_settings_path_validation() -> None:
"""Test that paths are validated and converted correctly."""
settings = Settings()
assert isinstance(settings.data_dir, Path)
assert isinstance(settings.models_dir, Path)
assert isinstance(settings.logs_dir, Path)
def test_settings_field_constraints() -> None:
"""Test that field constraints are enforced."""
# Label threshold should be between 1 and 9
with pytest.raises(ValidationError):
Settings(label_threshold=0.5)
with pytest.raises(ValidationError):
Settings(label_threshold=10.0)
def test_get_settings_cached() -> None:
"""Test that get_settings returns cached instance."""
settings1 = get_settings()
settings2 = get_settings()
assert settings1 is settings2
def test_create_directories(tmp_path: Path) -> None:
"""Test directory creation."""
settings = Settings(
data_dir=tmp_path / "data",
models_dir=tmp_path / "models",
logs_dir=tmp_path / "logs",
)
settings.create_directories()
assert settings.data_dir.exists()
assert settings.models_dir.exists()
assert settings.logs_dir.exists()