ConfigManager V2
This commit is contained in:
33
tests/v2/test_config_reload_fallback.py
Normal file
33
tests/v2/test_config_reload_fallback.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import asyncio
|
||||
|
||||
from config_manager.v2 import ConfigManagerV2
|
||||
|
||||
|
||||
class ReloadApp(ConfigManagerV2):
|
||||
def execute(self) -> None:
|
||||
return
|
||||
|
||||
|
||||
def test_invalid_config_keeps_last_valid(tmp_path):
|
||||
async def scenario() -> None:
|
||||
cfg = tmp_path / "config.yaml"
|
||||
cfg.write_text("work_interval: 0.2\nupdate_interval: 0.05\n", encoding="utf-8")
|
||||
|
||||
app = ReloadApp(str(cfg))
|
||||
runner = asyncio.create_task(app.start())
|
||||
|
||||
await asyncio.sleep(0.12)
|
||||
assert app.work_interval == 0.2
|
||||
assert app.update_interval == 0.05
|
||||
|
||||
cfg.write_text("work_interval: [broken\n", encoding="utf-8")
|
||||
await asyncio.sleep(0.15)
|
||||
|
||||
assert app.work_interval == 0.2
|
||||
assert app.update_interval == 0.05
|
||||
assert isinstance(app.config, dict)
|
||||
|
||||
await app.stop()
|
||||
await runner
|
||||
|
||||
asyncio.run(scenario())
|
||||
Reference in New Issue
Block a user