Add mockapi source files and tests
This commit is contained in:
@@ -27,12 +27,7 @@ class TestConfig:
|
|||||||
|
|
||||||
def test_load_from_dict(self):
|
def test_load_from_dict(self):
|
||||||
"""Test creating config with dict values."""
|
"""Test creating config with dict values."""
|
||||||
config = Config(
|
config = Config(port=3000, host="127.0.0.1", delay=100, seed=123)
|
||||||
port=3000,
|
|
||||||
host="127.0.0.1",
|
|
||||||
delay=100,
|
|
||||||
seed=123,
|
|
||||||
)
|
|
||||||
assert config.port == 3000
|
assert config.port == 3000
|
||||||
assert config.host == "127.0.0.1"
|
assert config.host == "127.0.0.1"
|
||||||
assert config.delay == 100
|
assert config.delay == 100
|
||||||
@@ -73,9 +68,7 @@ class TestConfig:
|
|||||||
"seed": 456,
|
"seed": 456,
|
||||||
}
|
}
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile(
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f:
|
||||||
mode="w", suffix=".yaml", delete=False
|
|
||||||
) as f:
|
|
||||||
yaml.dump(config_data, f)
|
yaml.dump(config_data, f)
|
||||||
temp_path = f.name
|
temp_path = f.name
|
||||||
|
|
||||||
@@ -93,9 +86,7 @@ class TestConfig:
|
|||||||
"""Test that environment variables override file config."""
|
"""Test that environment variables override file config."""
|
||||||
config_data = {"port": 7000, "host": "0.0.0.0"}
|
config_data = {"port": 7000, "host": "0.0.0.0"}
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile(
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f:
|
||||||
mode="w", suffix=".yaml", delete=False
|
|
||||||
) as f:
|
|
||||||
yaml.dump(config_data, f)
|
yaml.dump(config_data, f)
|
||||||
temp_path = f.name
|
temp_path = f.name
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user