ConfigManager V2
This commit is contained in:
30
tests/v2/test_contract_v2.py
Normal file
30
tests/v2/test_contract_v2.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import asyncio
|
||||
|
||||
from config_manager.v2 import ConfigManagerV2
|
||||
|
||||
|
||||
class DemoApp(ConfigManagerV2):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.calls = 0
|
||||
|
||||
def execute(self) -> None:
|
||||
self.calls += 1
|
||||
|
||||
|
||||
def test_execute_loop_runs(tmp_path):
|
||||
async def scenario() -> None:
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("work_interval: 0.05\nupdate_interval: 0.05\n", encoding="utf-8")
|
||||
|
||||
app = DemoApp(str(cfg))
|
||||
runner = asyncio.create_task(app.start())
|
||||
|
||||
await asyncio.sleep(0.18)
|
||||
await app.stop()
|
||||
await runner
|
||||
|
||||
assert app.calls >= 2
|
||||
assert isinstance(app.config, dict)
|
||||
|
||||
asyncio.run(scenario())
|
||||
Reference in New Issue
Block a user