Skip to content

Commit 1bb5a15

Browse files
committed
Rename authenticate_user -> generate_token
1 parent ecb325c commit 1bb5a15

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pusher_push_notifications/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def publish_to_users(self, user_ids, publish_body):
341341

342342
return response_body
343343

344-
def authenticate_user(self, user_id):
344+
def generate_token(self, user_id):
345345
"""Generate an auth token which will allow devices to associate
346346
themselves with the given user id
347347

tests/test_users.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919

2020
class TestPushNotificationsUsers(unittest.TestCase):
21-
def test_authenticate_user_should_return_token(self):
21+
def test_generate_token_should_return_token(self):
2222
user_id = 'user-0001'
2323
pn_client = PushNotifications(
2424
'INSTANCE_ID',
2525
'SECRET_KEY'
2626
)
2727

28-
token_string = pn_client.authenticate_user(user_id)
28+
token_string = pn_client.generate_token(user_id)
2929

3030
self.assertIsInstance(token_string, six.string_types)
3131
self.assertTrue(len(token_string) > 0)
@@ -44,24 +44,24 @@ def test_authenticate_user_should_return_token(self):
4444
self.assertIsNotNone(decoded_token.get('exp'))
4545
self.assertTrue(decoded_token.get('exp') > time.time())
4646

47-
def test_authenticate_user_should_fail_if_user_id_not_a_string(self):
47+
def test_generate_token_should_fail_if_user_id_not_a_string(self):
4848
user_id = False
4949
pn_client = PushNotifications(
5050
'INSTANCE_ID',
5151
'SECRET_KEY'
5252
)
5353
with self.assertRaises(TypeError) as e:
54-
pn_client.authenticate_user(user_id)
54+
pn_client.generate_token(user_id)
5555
self.assertIn('user_id must be a string', str(e.exception))
5656

57-
def test_authenticate_user_should_fail_if_user_id_too_long(self):
57+
def test_generate_token_should_fail_if_user_id_too_long(self):
5858
user_id = 'A' * 165
5959
pn_client = PushNotifications(
6060
'INSTANCE_ID',
6161
'SECRET_KEY'
6262
)
6363
with self.assertRaises(ValueError) as e:
64-
pn_client.authenticate_user(user_id)
64+
pn_client.generate_token(user_id)
6565
self.assertIn('longer than the maximum of 164 chars', str(e.exception))
6666

6767
def test_publish_to_users_should_make_correct_http_request(self):

0 commit comments

Comments
 (0)