fix: stray comma breaks sending notifications
This commit is contained in:
@@ -126,13 +126,15 @@ def should_notify(com_name):
|
||||
# check if this is an excluded species
|
||||
APPRISE_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 species
|
||||
APPRISE_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?
|
||||
|
||||
@@ -144,7 +144,13 @@ class TestAppriseNotifications(unittest.TestCase):
|
||||
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)
|
||||
|
||||
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_dict
|
||||
sendAppriseNotifications(**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_dict
|
||||
sendAppriseNotifications(**self.get_default_params())
|
||||
|
||||
self.assertEqual(mock_notify.call_count, 1)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user