"""Tests for I2CP session configuration.""" import pytest class TestSessionConfig: def test_defaults(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig() assert cfg.get("inbound.quantity") == "3" assert cfg.get("outbound.quantity") == "3" assert cfg.get("inbound.length") == "3" assert cfg.get("outbound.length") == "3" def test_override(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig({"inbound.quantity": "5", "custom.key": "val"}) assert cfg.get("inbound.quantity") == "5" assert cfg.get("custom.key") == "val" # Defaults still present for non-overridden keys assert cfg.get("outbound.quantity") == "3" def test_set_get(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig() cfg.set("my.option", "42") assert cfg.get("my.option") == "42" def test_get_missing_returns_none(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig() assert cfg.get("nonexistent") is None def test_get_missing_with_default(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig() assert cfg.get("nonexistent", "fallback") == "fallback" def test_merge(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig({"a": "1"}) cfg.merge({"b": "2", "a": "override"}) assert cfg.get("a") == "override" assert cfg.get("b") == "2" def test_to_properties(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig({"key": "val"}) props = cfg.to_properties() assert isinstance(props, dict) assert "key" in props def test_from_properties(self): from i2p_client.session_config import SessionConfig props = {"inbound.quantity": "5", "outbound.length": "2"} cfg = SessionConfig.from_properties(props) assert cfg.get("inbound.quantity") == "5" assert cfg.get("outbound.length") == "2" def test_tunnel_options(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig({ "inbound.quantity": "2", "inbound.length": "1", "inbound.backupQuantity": "0", "outbound.quantity": "2", "outbound.length": "1", "outbound.backupQuantity": "0", }) assert cfg.get("inbound.quantity") == "2" assert cfg.get("inbound.backupQuantity") == "0" def test_crypto_options(self): from i2p_client.session_config import SessionConfig cfg = SessionConfig({ "crypto.tagsToSend": "40", "crypto.lowTagThreshold": "30", }) assert cfg.get("crypto.tagsToSend") == "40" assert cfg.get("crypto.lowTagThreshold") == "30" def test_equality(self): from i2p_client.session_config import SessionConfig c1 = SessionConfig({"a": "1"}) c2 = SessionConfig({"a": "1"}) c3 = SessionConfig({"a": "2"}) assert c1 == c2 assert c1 != c3