Esempio n. 1
0
    def test_notification_enabled_reaming_days_greater_than_settings_should_do_nothing(
            self, helpersMock):
        tile = GarbageContainerScheduleTile('myGarbageScheduleTile',
                                            example_settings(True), 10)

        tile._send_notification(3, '')
        helpersMock.send_notification_via_pushbullet.assert_not_called()
Esempio n. 2
0
    def test_already_notified_should_skip_sending(self, requestsMock):
        tile = GarbageContainerScheduleTile('myGarbageScheduleTile',
                                            example_settings(True), 10)

        requestsMock.post.return_value.status_code = 200
        tile._send_notification(1, '')
        tile._send_notification(1, '')

        requestsMock.post.assert_called_once()
Esempio n. 3
0
    def test_already_notified_should_return_true(self):
        tile = GarbageContainerScheduleTile('myGarbageScheduleTile',
                                            example_settings(False), 10)

        tile._lastNotificationDate = datetime(year=2021, month=3,
                                              day=21).date()
        currentDateTime = datetime(year=2021,
                                   month=3,
                                   day=21,
                                   hour=11,
                                   minute=35,
                                   second=0)

        assert tile._is_already_notified(currentDateTime) is True
Esempio n. 4
0
    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:
            currentDateTimeMock.return_value = datetime(year=2021,
                                                        month=3,
                                                        day=21,
                                                        hour=9,
                                                        minute=35,
                                                        second=0)
            tile._send_notification(1, '')

        helpersMock.send_notification_via_pushbullet.assert_not_called()
Esempio n. 5
0
    def test_send_notification_after_settings_hour_should_call_pushbullet_api(
            self, requestsMock):
        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:
            currentDateTimeMock.return_value = datetime(year=2021,
                                                        month=3,
                                                        day=21,
                                                        hour=11,
                                                        minute=35,
                                                        second=0)
            tile._send_notification(1, '')

        requestsMock.post.assert_called_once_with(Helpers.PUSHBULLET_PUSH_URL,
                                                  data=mock.ANY,
                                                  headers=mock.ANY)
Esempio n. 6
0
    def test_notification_disabled_should_do_nothing(self, helpersMock):
        tile = GarbageContainerScheduleTile('myGarbageScheduleTile',
                                            example_settings(False), 10)

        tile._send_notification(1, '')
        helpersMock.send_notification_via_pushbullet.assert_not_called()
Esempio n. 7
0
 def test_not_notified_should_return_false(self):
     tile = GarbageContainerScheduleTile('myGarbageScheduleTile',
                                         example_settings(False), 10)
     assert tile._is_already_notified(datetime.now()) is False