From a91b6cb32bfeea712d8c483cc3dcd9020cfeb7f4 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Wed, 9 Oct 2024 23:38:15 +0200 Subject: [PATCH] fix tests --- .../tiles/TestGarbageContainerScheduleTile.py | 19 ++++++++++++++----- .../tile/tiles/TestSensorLineChartTile.py | 18 ++++++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/test/logic/tile/tiles/TestGarbageContainerScheduleTile.py b/test/logic/tile/tiles/TestGarbageContainerScheduleTile.py index ff2cad1..d2d9771 100644 --- a/test/logic/tile/tiles/TestGarbageContainerScheduleTile.py +++ b/test/logic/tile/tiles/TestGarbageContainerScheduleTile.py @@ -9,11 +9,18 @@ def example_settings(enableNotifications): return { "path": None, "garbageType": "Papier" or "Gelbe Säcke" or "Bioabfall" or "Restabfall", - "notificationViaPushbullet": { - "enable": enableNotifications, + "notification": { + "enableNotificationViaPushbullet": enableNotifications, "daysBeforeEvent": 1, "hour": 10, - "pushbulletToken": "myToken" + "pushbulletToken": "myToken", + 'enableNotificationViaNtfy': False, + 'ntfySettings': { + 'username': '', + 'password': '', + 'baseUrl': '', + 'topicName': '' + } } } @@ -60,7 +67,8 @@ class TestSendNotification: tile = GarbageContainerScheduleTile('myGarbageScheduleTile', example_settings(True), 10) requestsMock.post.return_value.status_code = 200 - with mock.patch.object(tile, '_get_current_date_time', wraps=tile._get_current_date_time) as currentDateTimeMock: + with mock.patch.object(tile, '_get_current_date_time', + wraps=tile._get_current_date_time) as currentDateTimeMock: currentDateTimeMock.return_value = datetime(year=2021, month=3, day=21, hour=11, minute=35, second=0) tile._send_notification(1, '') @@ -70,7 +78,8 @@ class TestSendNotification: def test_send_notification_before_settings_hour_should_do_nothing(self, helpersMock): tile = GarbageContainerScheduleTile('myGarbageScheduleTile', example_settings(True), 10) - with mock.patch.object(tile, '_get_current_date_time', wraps=tile._get_current_date_time) as currentDateTimeMock: + with mock.patch.object(tile, '_get_current_date_time', + wraps=tile._get_current_date_time) as currentDateTimeMock: currentDateTimeMock.return_value = datetime(year=2021, month=3, day=21, hour=9, minute=35, second=0) tile._send_notification(1, '') diff --git a/test/logic/tile/tiles/TestSensorLineChartTile.py b/test/logic/tile/tiles/TestSensorLineChartTile.py index 182913d..9a97420 100644 --- a/test/logic/tile/tiles/TestSensorLineChartTile.py +++ b/test/logic/tile/tiles/TestSensorLineChartTile.py @@ -177,7 +177,14 @@ class TestGetTimeSinceLastValue: 'enable': enable, 'limitInSeconds': 10, 'enableNotificationViaPushbullet': False, - 'pushbulletToken': None + 'pushbulletToken': None, + 'enableNotificationViaNtfy': False, + 'ntfySettings': { + 'username': '', + 'password': '', + 'baseUrl': '', + 'topicName': '' + } } def test_warnings_disabled_returns_empty_string(self): @@ -214,7 +221,14 @@ class TestSendNotification: 'enable': enable, 'limitInSeconds': 10, 'enableNotificationViaPushbullet': enableNotification, - 'pushbulletToken': 'myToken' + 'pushbulletToken': 'myToken', + 'enableNotificationViaNtfy': False, + 'ntfySettings': { + 'username': '', + 'password': '', + 'baseUrl': '', + 'topicName': '' + } } def __get_sensor_info(self) -> Dict[str, str]: -- GitLab