Zo doen wijdat in oost

This commit is contained in:
2026-10-16 07:20:44 +02:00
parent 25d9cb1c7d
commit 6f80a820da
229 changed files with 23894 additions and 74 deletions
+30
View File
@@ -1,5 +1,6 @@
# retoor <retoor@molodetz.nl>
import asyncio
import time
import pytest
@@ -146,3 +147,32 @@ def test_metrics_report_connected_and_capacity(service):
def test_the_service_has_the_kill_switch_as_a_config_field(service):
keys = [field.key for field in service.all_fields()]
assert "nodes_enabled" in keys and "nodes_max_total" in keys
def test_changed_settings_are_pushed_to_the_node_once(service):
uid = member()
device, socket = connected(service, uid)
session = service.registry.get(device["uid"])
session.settings = {"stale": True}
assert reconcile(service) == 0
pushed = [frame for frame in socket.sent if frame["type"] == "settings_update"]
assert len(pushed) == 1 and pushed[0]["settings"]["enabled"] is True
assert session.settings == pushed[0]["settings"]
reconcile(service)
assert len([frame for frame in socket.sent if frame["type"] == "settings_update"]) == 1
save_node_settings(uid, {"bandwidth_mb_day": 9})
reconcile(service)
assert session.settings["bandwidth_mb_day"] == 9
def test_the_dispatch_loop_starts_once_and_stops_with_the_service(service):
async def scenario():
service.ensure_dispatching()
first = service._dispatch_task
service.ensure_dispatching()
assert service._dispatch_task is first and not first.done()
await service.on_disable()
await asyncio.sleep(0)
assert service._dispatch_task is None and first.cancelled()
run_async(scenario())