A live bird collage card for your Home Assistant dashboard.
fix: stray comma breaks sending notifications
frederik8e5e2a2696d0
diff --git a/scripts/utils/notifications.py b/scripts/utils/notifications.pyindex f9580020..5c624e50 100644--- a/scripts/utils/notifications.py+++ b/scripts/utils/notifications.py@@ -126,13 +126,15 @@ def should_notify(com_name):# check if this is an excluded speciesAPPRISE_ONLY_NOTIFY_SPECIES_NAMES = settings_dict.get('APPRISE_ONLY_NOTIFY_SPECIES_NAMES')if APPRISE_ONLY_NOTIFY_SPECIES_NAMES is not None and APPRISE_ONLY_NOTIFY_SPECIES_NAMES.strip() != "":- if any(bird.lower().replace(" ", "") in com_name.lower().replace(" ", "") for bird in APPRISE_ONLY_NOTIFY_SPECIES_NAMES.split(",")):+ excluded_species = [bird.lower().replace(" ", "") for bird in APPRISE_ONLY_NOTIFY_SPECIES_NAMES.split(",")]+ if com_name.lower().replace(" ", "") in excluded_species:return False# check if this is an included speciesAPPRISE_ONLY_NOTIFY_SPECIES_NAMES_2 = settings_dict.get('APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2')if APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2 is not None and APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2.strip() != "":- if not any(bird.lower().replace(" ", "") in com_name.lower().replace(" ", "") for bird in APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2.split(",")):+ included_species = [bird.lower().replace(" ", "") for bird in APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2.split(",")]+ if com_name.lower().replace(" ", "") not in included_species:return False# is it still too soon?diff --git a/tests/test_apprise_notifications.py b/tests/test_apprise_notifications.pyindex 0269aa87..3f7605dd 100644--- a/tests/test_apprise_notifications.py+++ b/tests/test_apprise_notifications.py@@ -144,7 +144,13 @@ class TestAppriseNotifications(unittest.TestCase):settings_dict['APPRISE_ONLY_NOTIFY_SPECIES_NAMES'] = 'Quailfinch'mock_load_settings.return_value = settings_dictsendAppriseNotifications(**self.get_default_params())+ # Not excluded. Confirm notifications.+ self.assertEqual(mock_notify.call_count, 1)+ mock_notify.reset_mock()+ settings_dict['APPRISE_ONLY_NOTIFY_SPECIES_NAMES'] = 'Quailfinch,'+ mock_load_settings.return_value = settings_dict+ sendAppriseNotifications(**self.get_default_params())# Not excluded. Confirm notifications.self.assertEqual(mock_notify.call_count, 1)@@ -167,7 +173,12 @@ class TestAppriseNotifications(unittest.TestCase):settings_dict['APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2'] = 'Quailfinch'mock_load_settings.return_value = settings_dictsendAppriseNotifications(**self.get_default_params())+ # No wanted species. Confirm no notifications.+ self.assertEqual(mock_notify.call_count, 0)+ settings_dict['APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2'] = 'Quailfinch,'+ mock_load_settings.return_value = settings_dict+ sendAppriseNotifications(**self.get_default_params())# No wanted species. Confirm no notifications.self.assertEqual(mock_notify.call_count, 0)@@ -175,7 +186,6 @@ class TestAppriseNotifications(unittest.TestCase):settings_dict['APPRISE_ONLY_NOTIFY_SPECIES_NAMES_2'] = 'Quailfinch,Great Crested Flycatcher'mock_load_settings.return_value = settings_dictsendAppriseNotifications(**self.get_default_params())-self.assertEqual(mock_notify.call_count, 1)