コード例 #1
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def test_get_auth_access_token_exists(self):
     """
     If a token exists in the given session's AUTH_ACCESS_TOKEN,
     get_auth_access_token() should return that token.
     """
     session = self.client.session
     spotify._set_auth_access_token(session, 'token123', 1)
     self.assertEqual(spotify._get_auth_access_token(session), 'token123')
コード例 #2
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def test_set_auth_access_token(self):
     """
     set_auth_access_token() should set the variable associated with
     AUTH_ACCESS_TOKEN in the given session to the given token.
     """
     session = self.client.session
     spotify._set_auth_access_token(session, 'token123', 1)
     self.assertEqual(session.get(spotify.AUTH_ACCESS_TOKEN), 'token123')
コード例 #3
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def test_clear_auth_access_token(self):
     """
     _clear_auth_access_token() should delete any saved token in the
     session's AUTH_ACCESS_TOKEN.
     """
     session = self.client.session
     spotify._set_auth_access_token(session, 'token123', 1)
     spotify._clear_auth_access_token(session)
     self.assertIsNone(session.get(spotify.AUTH_ACCESS_TOKEN))
コード例 #4
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def setUp(self):
     """
     Creates a fresh session with the authorized data retrieved in
     setUpClass().
     """
     self.session = create_session_store()
     spotify._set_refresh_token(self.session, self.refresh_token)
     spotify._set_user_id(self.session, self.user_id)
     spotify._set_auth_access_token(self.session, self.auth_access_token,
                                    10)
コード例 #5
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def test_set_auth_access_token_timeout(self):
     """
     _set_auth_access_token() should save the given token in the
     given session under AUTH_ACCESS_TOKEN, and should delete it
     after the given timeout (in seconds).
     """
     session = self.client.session
     spotify._set_auth_access_token(session, 'token123', 1)
     time.sleep(1)
     self.assertIsNone(session.get(spotify.AUTH_ACCESS_TOKEN))
コード例 #6
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def test_logout_logged_in(self):
     """
     logout() should set all the user's session variables to None.
     """
     session = self.client.session
     spotify._set_refresh_token(session, 'this_is_a_code')
     spotify._set_user_id(session, 'user_id')
     spotify._set_auth_access_token(session, 'token123', 3)
     spotify.logout(session)
     self.assertIsNone(session.get(spotify.REFRESH_TOKEN))
     self.assertIsNone(session.get(spotify.USER_ID))
     self.assertIsNone(session.get(spotify.AUTH_ACCESS_TOKEN))