mirror of https://github.com/zulip/zulip.git
APNs: Fix a case I broke while working out tests.
I got distracted, came back later to a successful test run in my terminal, and thought I remembered finishing the change and just kicking off a final test run to check. In fact, there was an `assert False` right in the normal case for production, and I just hadn't finished a test for that path. (m.-) Definitely the most grateful I've been for our coverage checks, which highlighted this for me. Remove the `assert False`, and also finish writing the test it was there to help me write. Those lines are covered now.
This commit is contained in:
parent
59f61c2525
commit
8be2dfa81c
|
@ -66,7 +66,6 @@ def get_apns_client() -> APNsClient:
|
||||||
if settings.APNS_CERT_FILE is not None:
|
if settings.APNS_CERT_FILE is not None:
|
||||||
_apns_client = APNsClient(credentials=settings.APNS_CERT_FILE,
|
_apns_client = APNsClient(credentials=settings.APNS_CERT_FILE,
|
||||||
use_sandbox=settings.APNS_SANDBOX)
|
use_sandbox=settings.APNS_SANDBOX)
|
||||||
assert False
|
|
||||||
_apns_client_initialized = True
|
_apns_client_initialized = True
|
||||||
return _apns_client
|
return _apns_client
|
||||||
|
|
||||||
|
|
|
@ -565,6 +565,12 @@ class TestAPNs(PushNotificationTest):
|
||||||
apn.send_apple_push_notification(
|
apn.send_apple_push_notification(
|
||||||
self.user_profile.id, devices, payload_data)
|
self.user_profile.id, devices, payload_data)
|
||||||
|
|
||||||
|
def test_get_apns_client(self) -> None:
|
||||||
|
with self.settings(APNS_CERT_FILE='/foo.pem'), \
|
||||||
|
mock.patch('zerver.lib.push_notifications.APNsClient') as mock_client:
|
||||||
|
client = get_apns_client()
|
||||||
|
self.assertEqual(mock_client.return_value, client)
|
||||||
|
|
||||||
def test_not_configured(self) -> None:
|
def test_not_configured(self) -> None:
|
||||||
with mock.patch('zerver.lib.push_notifications.get_apns_client') as mock_get, \
|
with mock.patch('zerver.lib.push_notifications.get_apns_client') as mock_get, \
|
||||||
mock.patch('zerver.lib.push_notifications.logging') as mock_logging:
|
mock.patch('zerver.lib.push_notifications.logging') as mock_logging:
|
||||||
|
|
Loading…
Reference in New Issue