added logging
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest.mock import patch
|
||||
|
||||
from lib._zyxel import normalize_mac
|
||||
@@ -52,6 +54,20 @@ class NotificationTests(unittest.TestCase):
|
||||
timeout=4.0,
|
||||
)
|
||||
|
||||
@patch("lib._arrival_detection.send_notification")
|
||||
def test_appends_notification_to_event_log(self, send_notification):
|
||||
with TemporaryDirectory() as directory:
|
||||
event_log = Path(directory) / "arrivals.txt"
|
||||
config = {
|
||||
"notification": {
|
||||
"enabled": True,
|
||||
"message": "{name} arrived home",
|
||||
"event_log": str(event_log),
|
||||
}
|
||||
}
|
||||
_notify(config, {"name": "Ignace", "mac": "aa:bb:cc:dd:ee:ff"})
|
||||
self.assertTrue(event_log.read_text().endswith(" Ignace arrived home\n"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user