update tests/unit/test_source_config.py
Browse files
tests/unit/test_source_config.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
from app.models.source import SourceConfig, SourceType
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def test_source_config_creation():
|
| 6 |
+
"""Test that SourceConfig model can be created with required fields."""
|
| 7 |
+
source = SourceConfig(
|
| 8 |
+
url="https://github.com/user/proxies/raw/main/list.txt",
|
| 9 |
+
type=SourceType.GITHUB_RAW,
|
| 10 |
+
enabled=True,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
assert str(source.url) == "https://github.com/user/proxies/raw/main/list.txt"
|
| 14 |
+
assert source.type == SourceType.GITHUB_RAW
|
| 15 |
+
assert source.enabled is True
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def test_source_config_defaults():
|
| 19 |
+
"""Test default values for optional fields."""
|
| 20 |
+
source = SourceConfig(
|
| 21 |
+
url="https://example.com/proxies.txt", type=SourceType.GENERIC_TEXT
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
assert source.enabled is True
|
| 25 |
+
assert source.selector is None
|
| 26 |
+
assert source.interval == 3600
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def test_source_type_enum():
|
| 30 |
+
"""Test that SourceType enum contains all required types."""
|
| 31 |
+
assert hasattr(SourceType, "GITHUB_RAW")
|
| 32 |
+
assert hasattr(SourceType, "SUBSCRIPTION_BASE64")
|
| 33 |
+
assert hasattr(SourceType, "GENERIC_TEXT")
|