Add type annotations (PEP 484) (#25)
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@ from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from apns2.client import APNsClient, CONCURRENT_STREAMS_SAFETY_MAXIMUM, Notification
|
||||
from apns2.client import APNsClient, CertificateCredentials, CONCURRENT_STREAMS_SAFETY_MAXIMUM, Notification
|
||||
from apns2.errors import ConnectionFailed
|
||||
from apns2.payload import Payload
|
||||
|
||||
@@ -26,7 +26,7 @@ def notifications(tokens):
|
||||
def client(mock_connection):
|
||||
with patch('apns2.credentials.HTTP20Connection') as mock_connection_constructor:
|
||||
mock_connection_constructor.return_value = mock_connection
|
||||
return APNsClient(credentials=None)
|
||||
return APNsClient(credentials=CertificateCredentials())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
+12
-12
@@ -8,10 +8,10 @@ def payload_alert():
|
||||
return PayloadAlert(
|
||||
title='title',
|
||||
title_localized_key='loc_k',
|
||||
title_localized_args='loc_a',
|
||||
title_localized_args=['loc_a'],
|
||||
body='body',
|
||||
body_localized_key='body_loc_k',
|
||||
body_localized_args='body_loc_a',
|
||||
body_localized_args=['body_loc_a'],
|
||||
action_localized_key='ac_loc_k',
|
||||
action='send',
|
||||
launch_image='img'
|
||||
@@ -22,10 +22,10 @@ def test_payload_alert(payload_alert):
|
||||
assert payload_alert.dict() == {
|
||||
'title': 'title',
|
||||
'title-loc-key': 'loc_k',
|
||||
'title-loc-args': 'loc_a',
|
||||
'title-loc-args': ['loc_a'],
|
||||
'body': 'body',
|
||||
'loc-key': 'body_loc_k',
|
||||
'loc-args': 'body_loc_a',
|
||||
'loc-args': ['body_loc_a'],
|
||||
'action-loc-key': 'ac_loc_k',
|
||||
'action': 'send',
|
||||
'launch-image': 'img'
|
||||
@@ -35,8 +35,8 @@ def test_payload_alert(payload_alert):
|
||||
def test_payload():
|
||||
payload = Payload(
|
||||
alert='my_alert', badge=2, sound='chime',
|
||||
content_available=1, mutable_content=3,
|
||||
category='my_category', url_args='args', custom={'extra': 'something'}, thread_id=42)
|
||||
content_available=True, mutable_content=True,
|
||||
category='my_category', url_args='args', custom={'extra': 'something'}, thread_id='42')
|
||||
assert payload.dict() == {
|
||||
'aps': {
|
||||
'alert': 'my_alert',
|
||||
@@ -44,7 +44,7 @@ def test_payload():
|
||||
'sound': 'chime',
|
||||
'content-available': 1,
|
||||
'mutable-content': 1,
|
||||
'thread-id': 42,
|
||||
'thread-id': '42',
|
||||
'category': 'my_category',
|
||||
'url-args': 'args'
|
||||
},
|
||||
@@ -55,17 +55,17 @@ def test_payload():
|
||||
def test_payload_with_payload_alert(payload_alert):
|
||||
payload = Payload(
|
||||
alert=payload_alert, badge=2, sound='chime',
|
||||
content_available=1, mutable_content=1,
|
||||
category='my_category', url_args='args', custom={'extra': 'something'}, thread_id=42)
|
||||
content_available=True, mutable_content=True,
|
||||
category='my_category', url_args='args', custom={'extra': 'something'}, thread_id='42')
|
||||
assert payload.dict() == {
|
||||
'aps': {
|
||||
'alert': {
|
||||
'title': 'title',
|
||||
'title-loc-key': 'loc_k',
|
||||
'title-loc-args': 'loc_a',
|
||||
'title-loc-args': ['loc_a'],
|
||||
'body': 'body',
|
||||
'loc-key': 'body_loc_k',
|
||||
'loc-args': 'body_loc_a',
|
||||
'loc-args': ['body_loc_a'],
|
||||
'action-loc-key': 'ac_loc_k',
|
||||
'action': 'send',
|
||||
'launch-image': 'img'
|
||||
@@ -74,7 +74,7 @@ def test_payload_with_payload_alert(payload_alert):
|
||||
'sound': 'chime',
|
||||
'content-available': 1,
|
||||
'mutable-content': 1,
|
||||
'thread-id': 42,
|
||||
'thread-id': '42',
|
||||
'category': 'my_category',
|
||||
'url-args': 'args',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user