@@ -579,6 +579,7 @@ def test_process_no_refresh_token(self):
579579 call ("Cache-Control" ,
580580 "no-store" ),
581581 call ("Pragma" , "no-cache" )])
582+
582583 @patch ("time.time" , mock_time )
583584 def test_process_with_refresh_token (self ):
584585 token_data = {"access_token" : "abcd" , "token_type" : "Bearer" ,
@@ -670,12 +671,12 @@ def test_process_with_unique_access_token_not_found(self):
670671 response = Response ()
671672
672673 access_token_store_mock = Mock (spec = AccessTokenStore )
673- access_token_store_mock .fetch_existing_token_of_user .\
674+ access_token_store_mock .fetch_existing_token_of_user . \
674675 side_effect = AccessTokenNotFound
675676
676677 token_generator_mock = Mock (spec = TokenGenerator )
677678 token_generator_mock .refresh_expires_in = 10000
678- token_generator_mock .create_access_token_data .\
679+ token_generator_mock .create_access_token_data . \
679680 return_value = token_data
680681
681682 handler = AuthorizationCodeTokenHandler (
@@ -866,7 +867,6 @@ def test_process_redirect_with_token(self):
866867 self .assertEqual (responseMock .content , "" )
867868 self .assertEqual (result_response , responseMock )
868869
869-
870870 def test_process_redirect_with_state (self ):
871871 """
872872 ImplicitGrantHandler should include the value of the "state" query parameter from request in redirect
@@ -916,7 +916,8 @@ def test_process_with_scope(self):
916916 state = "XHGFI"
917917 token = "tokencode"
918918
919- expected_redirect_uri = "%s#access_token=%s&token_type=bearer&state=%s&scope=%s" % (redirect_uri , token , state , scopes_uri )
919+ expected_redirect_uri = "%s#access_token=%s&token_type=bearer&state=%s&scope=%s" % (
920+ redirect_uri , token , state , scopes_uri )
920921
921922 response_mock = Mock (spec = Response )
922923
@@ -1516,6 +1517,7 @@ def test_call_other_grant_type(self):
15161517
15171518 self .assertEqual (grant_handler , None )
15181519
1520+
15191521class RefreshTokenHandlerTestCase (unittest .TestCase ):
15201522 @patch ("time.time" , mock_time )
15211523 def test_process_no_reissue (self ):
@@ -1537,7 +1539,7 @@ def test_process_no_reissue(self):
15371539 scope_handler_mock = Mock (spec = Scope )
15381540 scope_handler_mock .scopes = scopes
15391541
1540- token_data = {"access_token" : token , "expires_in" :expires_in , "token_type" : "Bearer" , "refresh_token" :"gafc" }
1542+ token_data = {"access_token" : token , "expires_in" : expires_in , "token_type" : "Bearer" , "refresh_token" : "gafc" }
15411543 token_generator_mock = Mock (spec = TokenGenerator )
15421544 token_generator_mock .create_access_token_data .return_value = token_data
15431545 token_generator_mock .refresh_expires_in = 1200
@@ -1588,7 +1590,8 @@ def test_process_with_reissue(self):
15881590 scope_handler_mock = Mock (spec = Scope )
15891591 scope_handler_mock .scopes = scopes
15901592
1591- token_data = {"access_token" : token , "expires_in" :expires_in , "token_type" : "Bearer" , "refresh_token" :refresh_token }
1593+ token_data = {"access_token" : token , "expires_in" : expires_in , "token_type" : "Bearer" ,
1594+ "refresh_token" : refresh_token }
15921595 token_generator_mock = Mock (spec = TokenGenerator )
15931596 token_generator_mock .create_access_token_data .return_value = token_data
15941597 token_generator_mock .refresh_expires_in = 1200
@@ -1618,7 +1621,6 @@ def test_process_with_reissue(self):
16181621 self .assertDictContainsSubset (expected_headers , result .headers )
16191622 self .assertDictEqual (expected_response_body , json .loads (result .body ))
16201623
1621-
16221624 @patch ("time.time" , mock_time )
16231625 def test_read_validate_params (self ):
16241626 client_id = "client"
@@ -1645,7 +1647,7 @@ def test_read_validate_params(self):
16451647 request_mock = Mock (spec = Request )
16461648 request_mock .post_param .side_effect = [refresh_token ]
16471649
1648- token_generator_mock = Mock (expires_in = {'test_grant_type' :600 })
1650+ token_generator_mock = Mock (expires_in = {'test_grant_type' : 600 })
16491651 token_generator_mock .refresh_expires_in = 0
16501652
16511653 scope_handler_mock = Mock (spec = Scope )
@@ -1738,7 +1740,7 @@ def test_read_validate_params_expired_refresh_token(self):
17381740 access_token_store = access_token_store_mock ,
17391741 client_authenticator = client_auth_mock ,
17401742 scope_handler = Mock (),
1741- token_generator = Mock (expires_in = {'test_grant_type' :600 }))
1743+ token_generator = Mock (expires_in = {'test_grant_type' : 600 }))
17421744
17431745 with self .assertRaises (OAuthInvalidError ) as expected :
17441746 handler .read_validate_params (request_mock )
@@ -1811,7 +1813,6 @@ def test_call_other_grant_type(self):
18111813class ClientCredentialsHandlerTestCase (unittest .TestCase ):
18121814 def test_process (self ):
18131815 client_id = "abc"
1814- expires_in = 0
18151816 token = "abcd"
18161817
18171818 expected_response_body = {"access_token" : token ,
@@ -1827,7 +1828,7 @@ def test_process(self):
18271828
18281829 token_generator_mock = Mock (spec = TokenGenerator )
18291830 token_generator_mock .generate .return_value = token
1830- token_generator_mock .expires_in = {ClientCredentialsGrant . grant_type : expires_in }
1831+ token_generator_mock .expires_in = {}
18311832 handler = ClientCredentialsHandler (
18321833 access_token_store = access_token_store_mock ,
18331834 client_authenticator = Mock (),
@@ -1862,7 +1863,7 @@ def test_process_with_refresh_token(self):
18621863
18631864 token_generator_mock = Mock (spec = TokenGenerator )
18641865 token_generator_mock .generate .return_value = token
1865- token_generator_mock .expires_in = {ClientCredentialsGrant .grant_type :expires_in }
1866+ token_generator_mock .expires_in = {ClientCredentialsGrant .grant_type : expires_in }
18661867
18671868 handler = ClientCredentialsHandler (
18681869 access_token_store = access_token_store_mock ,
@@ -1916,5 +1917,6 @@ def test_read_validate_params(self):
19161917 scope_handler_mock .parse .assert_called_with (request = request_mock ,
19171918 source = "body" )
19181919
1920+
19191921if __name__ == "__main__" :
19201922 unittest .main ()
0 commit comments