bunch of bugs

This commit is contained in:
2026-08-26 18:17:03 +02:00
parent c5b598b522
commit 1e73476830
7 changed files with 77 additions and 9 deletions
+37 -1
View File
@@ -78,7 +78,43 @@ class ArrivalDetectorTests(unittest.TestCase):
"event": "arrived",
"id": "ignace",
"text": "",
}
},
{
"sender": "_arrival_detection",
"event": "first_arrival",
"id": "ignace",
"text": "",
},
],
)
@patch("lib._arrival_detection._build_router")
def test_first_arrival_fires_only_when_empty_house_becomes_occupied(
self, _build_router
):
events = []
monitor = ArrivalMonitor(
{
"devices": [
{"id": "ignace", "mac": "00:00:00:00:00:01"},
{"id": "janine", "mac": "00:00:00:00:00:02"},
],
"polling": {"absent_after": 1, "present_after": 1},
},
events.append,
)
first = "00:00:00:00:00:01"
second = "00:00:00:00:00:02"
monitor._process_states({first: False, second: False})
monitor._process_states({first: True, second: False})
monitor._process_states({first: True, second: True})
self.assertEqual(
[(event["event"], event["id"]) for event in events],
[
("arrived", "ignace"),
("first_arrival", "ignace"),
("arrived", "janine"),
],
)