18
18
19
19
20
20
class TestPushNotificationsUsers (unittest .TestCase ):
21
- def test_authenticate_user_should_return_token (self ):
21
+ def test_generate_token_should_return_token (self ):
22
22
user_id = 'user-0001'
23
23
pn_client = PushNotifications (
24
24
'INSTANCE_ID' ,
25
25
'SECRET_KEY'
26
26
)
27
27
28
- token_string = pn_client .authenticate_user (user_id )
28
+ token_string = pn_client .generate_token (user_id )
29
29
30
30
self .assertIsInstance (token_string , six .string_types )
31
31
self .assertTrue (len (token_string ) > 0 )
@@ -44,24 +44,24 @@ def test_authenticate_user_should_return_token(self):
44
44
self .assertIsNotNone (decoded_token .get ('exp' ))
45
45
self .assertTrue (decoded_token .get ('exp' ) > time .time ())
46
46
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 ):
48
48
user_id = False
49
49
pn_client = PushNotifications (
50
50
'INSTANCE_ID' ,
51
51
'SECRET_KEY'
52
52
)
53
53
with self .assertRaises (TypeError ) as e :
54
- pn_client .authenticate_user (user_id )
54
+ pn_client .generate_token (user_id )
55
55
self .assertIn ('user_id must be a string' , str (e .exception ))
56
56
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 ):
58
58
user_id = 'A' * 165
59
59
pn_client = PushNotifications (
60
60
'INSTANCE_ID' ,
61
61
'SECRET_KEY'
62
62
)
63
63
with self .assertRaises (ValueError ) as e :
64
- pn_client .authenticate_user (user_id )
64
+ pn_client .generate_token (user_id )
65
65
self .assertIn ('longer than the maximum of 164 chars' , str (e .exception ))
66
66
67
67
def test_publish_to_users_should_make_correct_http_request (self ):
0 commit comments