Groups every flat test_*.py under the module it exercises, matching the
existing tests/{profiler,sniffer,prober,collector,correlation,cli,web,
topology,swarm,bus,updater,api,docker,geoip,...} layout. New folders:
services/, fleet/, config/, logging/, db/ (+ db/mysql/), telemetry/,
mutator/, core/.
Path-dependent __file__ references bumped an extra .parent in three
files that moved one level deeper:
- tests/sniffer/test_sniffer_ja3.py (template path)
- tests/services/test_ssh_capture_emit.py (template path)
- tests/cli/test_mode_gating.py (REPO root)
- tests/web/test_env_lazy_jwt.py (repo var)
Also drops two SQLite runtime artifacts (test_decnet.db-{shm,wal}) that
were leaking into the repo from a previous test run.
Fixes two test_service_isolation cases that patched asyncio.sleep (no
longer on the profiler main-loop hot path — same pre-existing bug I
fixed earlier in test_attacker_worker.py) by patching asyncio.wait_for
and passing interval=0.
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import pytest
|
|
from decnet.ini_loader import load_ini_from_string, validate_ini_string
|
|
|
|
def test_validate_ini_string_too_large():
|
|
content = "[" + "a" * (512 * 1024 + 1) + "]"
|
|
with pytest.raises(ValueError, match="too large"):
|
|
validate_ini_string(content)
|
|
|
|
def test_validate_ini_string_empty():
|
|
with pytest.raises(ValueError, match="is empty"):
|
|
validate_ini_string("")
|
|
with pytest.raises(ValueError, match="is empty"):
|
|
validate_ini_string(" ")
|
|
|
|
def test_validate_ini_string_no_sections():
|
|
with pytest.raises(ValueError, match="no sections found"):
|
|
validate_ini_string("key=value")
|
|
|
|
def test_load_ini_from_string_amount_limit():
|
|
content = """
|
|
[general]
|
|
net=192.168.1.0/24
|
|
|
|
[decky-01]
|
|
amount=101
|
|
archetype=linux-server
|
|
"""
|
|
with pytest.raises(ValueError, match="exceeds maximum allowed"):
|
|
load_ini_from_string(content)
|
|
|
|
def test_load_ini_from_string_valid():
|
|
content = """
|
|
[general]
|
|
net=192.168.1.0/24
|
|
|
|
[decky-01]
|
|
amount=5
|
|
archetype=linux-server
|
|
"""
|
|
cfg = load_ini_from_string(content)
|
|
assert len(cfg.deckies) == 5
|