Fix _is_expired_token issues (#47)

This commit is contained in:
SearchDream
2017-11-17 15:59:33 +03:00
committed by Sergey Petrov
parent c272fa8bf2
commit bbe8528acf
4 changed files with 15 additions and 10 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ class TokenCredentials(Credentials):
@staticmethod
def _is_expired_token(issue_date):
return time.time() < issue_date + DEFAULT_TOKEN_LIFETIME
return time.time() > issue_date + DEFAULT_TOKEN_LIFETIME
@staticmethod
def _get_signing_key(key_path):
+1
View File
@@ -1 +1,2 @@
freezegun
mock; python_version < '3.3'
+10 -6
View File
@@ -6,6 +6,8 @@
from unittest import TestCase, main
from freezegun import freeze_time
import time
from apns2.credentials import TokenCredentials
@@ -28,12 +30,14 @@ class TokenCredentialsTestCase(TestCase):
self.team_id)
self.lasting_header = self.normal_creds.get_authorization_header(
self.topics[0])
self.expiring_creds = \
TokenCredentials(self.key_path, self.key_id,
self.team_id,
token_lifetime=self.token_lifetime)
self.expiring_header = self.expiring_creds.get_authorization_header(
self.topics[0])
with freeze_time('2012-01-14'):
self.expiring_creds = \
TokenCredentials(self.key_path, self.key_id,
self.team_id,
token_lifetime=self.token_lifetime)
self.expiring_header = self.expiring_creds.get_authorization_header(
self.topics[0])
def test_create_multiple_topics(self):
h1 = self.normal_creds.get_authorization_header(self.topics[0])
+3 -3
View File
@@ -4,8 +4,8 @@ envlist = py27, py34, py35, py36
[testenv]
commands = nosetests []
deps =
nose
py27: mock
deps =
nose
-rrequirements-dev.txt
usedevelop=True