Files
ddns-monitor/tests/contracts/conftest.py
T
kiskaadee 8c13fb30aa test(contracts): add verified DuckDNS Class A contract assertions and specification
- Add test_duckdns_contract.py asserting token auth, prefix targeting, and verbose mode
- Add duckdns_config fixture in conftest.py
- Document DuckDNS protocol quirks and verbose 4-line block format in docs/contracts/class-a-duckdns.md
- Make Dynu test_bad_credentials assertion resilient to remote IP match short-circuiting
- Add .envrc for direnv integration
2026-10-29 13:18:25 -05:00

41 lines
1.4 KiB
Python

import tomllib
from pathlib import Path
import pytest
CONFIG_PATH = Path(__file__).parent / "contracts.local.toml"
@pytest.fixture(scope="session")
def raw_config():
if not CONFIG_PATH.exists():
pytest.skip(f"Contract test configuration not found at {CONFIG_PATH}")
with open(CONFIG_PATH, "rb") as f:
return tomllib.load(f)
@pytest.fixture(scope="session")
def general_config(raw_config):
return raw_config.get("general", {})
@pytest.fixture(scope="session")
def dynu_config(raw_config, general_config):
cfg = raw_config.get("dynu", {})
if not cfg.get("enabled", False):
pytest.skip("Dynu contract tests are disabled in contracts.local.toml")
return {
**{k: v.strip() if isinstance(v, str) else v for k, v in cfg.items()},
"test_ipv4": str(general_config.get("test_ipv4", "198.51.100.42")).strip(),
"test_ipv6": str(general_config.get("test_ipv6", "2001:db8::42")).strip(),
}
@pytest.fixture(scope="session")
def duckdns_config(raw_config, general_config):
cfg = raw_config.get("duckdns", {})
if not cfg.get("enabled", False):
pytest.skip("DuckDNS contract tests are disabled in contracts.local.toml")
return {
**{k: v.strip() if isinstance(v, str) else v for k, v in cfg.items()},
"test_ipv4": str(general_config.get("test_ipv4", "198.51.100.42")).strip(),
"test_ipv6": str(general_config.get("test_ipv6", "2001:db8::42")).strip(),
}