def test_make_provider_token_calls_jwt_encode_with_correct_args(self):
"""
Test that APNSConnection.make_provider_token() calls jwt.encode() with the correct
arguments. jwt.encode() returns different results each time even with the same data passed in
so we cannot just test for the expected return value.
"""
issued_at = time.time()
connection = jwt_apns_client.APNSConnection(
team_id='TEAMID',
apns_key_id='KEYID',
apns_key_path=self.KEY_FILE_PATH)
with mock.patch('jwt_apns_client.utils.jwt.encode') as mock_encode:
connection.make_provider_token(issued_at=issued_at)
mock_encode.assert_called_with(
{
'iss': connection.team_id,
'iat': issued_at
},
connection.secret,
algorithm=connection.algorithm,
headers=connection.get_token_headers())
评论列表
文章目录