def test__notify_recipients__unconfigured_unit(mocker, settings): log_mock = mocker.patch('dingdongditch.notifier.logger') settings(UNIT_1=system_settings.Unit( id='1234', buzzer=None, bell=None, strike=None)) notifier.notify_recipients('1234') log_mock.warning.assert_called_with( 'Unit found but not yet configured: %s', '1234')
def test__notify_recipients__should_push_to_recipients(mocker, settings): log_mock = mocker.patch('dingdongditch.notifier.logger') settings(UNIT_1=system_settings.Unit( id='1234', buzzer=None, bell=None, strike=None)) get_unit_by_id_mock = mocker.patch( 'dingdongditch.user_settings.get_unit_by_id') get_unit_by_id_mock.return_value = user_settings.Unit( should_ring_bell=False, recipients={'asdf1234=': 2}) notify_mock = mocker.patch('dingdongditch.notifier.notify') notifier.notify_recipients('1234') assert not log_mock.warning.called notify_mock.assert_called_with('1234', 'asdf1234=', 2, None)
def test__notify_recipients__no_network__with_fallback(mocker, settings): log_mock = mocker.patch('dingdongditch.notifier.logger') settings(RING_FALLBACK=True, UNIT_1=system_settings.Unit(id='1234', buzzer=None, bell=None, strike=None)) get_unit_by_id_mock = mocker.patch( 'dingdongditch.user_settings.get_unit_by_id') get_unit_by_id_mock.return_value = user_settings.Unit( should_ring_bell=False, recipients={'+14155551001': 1}) notify_mock = mocker.patch('dingdongditch.notifier.notify') notify_mock.return_value = False ring_mock = mocker.patch('dingdongditch.notifier.ring') notifier.notify_recipients('1234') log_mock.error.assert_called_with('All notifications failed!') assert ring_mock.called