logging: Change missing push notification keys from error to warning.

This is a configuration problem, but it just means a feature is not
enabled, not that attention is required, so it should be a warning,
not an error.
This commit is contained in:
Tim Abbott
2017-04-25 13:51:27 -07:00
parent b6094b8e91
commit c0d7e83333
2 changed files with 8 additions and 8 deletions

View File

@@ -166,8 +166,8 @@ def send_apple_push_notification_to_user(user, alert, **extra_data):
def send_apple_push_notification(user_id, devices, **extra_data): def send_apple_push_notification(user_id, devices, **extra_data):
# type: (int, List[PushDeviceToken], **Any) -> None # type: (int, List[PushDeviceToken], **Any) -> None
if not connection and not dbx_connection: if not connection and not dbx_connection:
logging.error("Attempting to send push notification, but no connection was found. " logging.warning("Attempting to send push notification, but no connection was found. "
"This may be because we could not find the APNS Certificate file.") "This may be because we could not find the APNS Certificate file.")
return return
# Plain b64 token kept for debugging purposes # Plain b64 token kept for debugging purposes
@@ -223,7 +223,7 @@ def send_android_push_notification_to_user(user_profile, data):
def send_android_push_notification(devices, data): def send_android_push_notification(devices, data):
# type: (List[PushDeviceToken], Dict[str, Any]) -> None # type: (List[PushDeviceToken], Dict[str, Any]) -> None
if not gcm: if not gcm:
logging.error("Attempting to send a GCM push notification, but no API key was configured") logging.warning("Attempting to send a GCM push notification, but no API key was configured")
return return
reg_ids = [device.token for device in devices] reg_ids = [device.token for device in devices]

View File

@@ -422,14 +422,14 @@ class GCMTest(PushNotificationTest):
return data return data
class GCMNotSetTest(GCMTest): class GCMNotSetTest(GCMTest):
@mock.patch('logging.error') @mock.patch('logging.warning')
def test_gcm_is_none(self, mock_error): def test_gcm_is_none(self, mock_warning):
# type: (mock.MagicMock) -> None # type: (mock.MagicMock) -> None
apn.gcm = None apn.gcm = None
apn.send_android_push_notification_to_user(self.user_profile, {}) apn.send_android_push_notification_to_user(self.user_profile, {})
mock_error.assert_called_with("Attempting to send a GCM push " mock_warning.assert_called_with("Attempting to send a GCM push "
"notification, but no API key was " "notification, but no API key was "
"configured") "configured")
class GCMSuccessTest(GCMTest): class GCMSuccessTest(GCMTest):
@mock.patch('logging.warning') @mock.patch('logging.warning')