コード例 #1
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
    def test_set_refresh_token(self):
        """
        set_refresh_token() should set the variable associated with
        REFRESH_TOKEN in the given session to the given code.
        """

        session = self.client.session
        spotify._set_refresh_token(session, 'this_is_a_code')
        self.assertIs(session.get(spotify.REFRESH_TOKEN), 'this_is_a_code')
コード例 #2
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def test_is_user_logged_in_false_uri_refresh(self):
     """
     is_user_logged_in() should return whether or not a user is
     logged in to a given session. If REFRESH_TOKEN is set and
     USER_ID is not, it should return False.
     """
     session = self.client.session
     spotify._set_refresh_token(session, 'code1')
     self.assertFalse(spotify.is_user_logged_in(session))
コード例 #3
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)
コード例 #4
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
 def test_is_user_logged_in_false_invalid_code(self):
     """
     is_user_logged_in() should return whether or not a user is
     logged in to a given session. If REFRESH_TOKEN and USER_ID are
     set, but the token is invalid or has expired, it should return
     False.
     """
     session = self.client.session
     spotify._set_refresh_token(session, 'code1')
     spotify._set_user_id(session, 'user')
     self.assertFalse(spotify.is_user_logged_in(session))
コード例 #5
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))
コード例 #6
0
ファイル: test_spotify.py プロジェクト: bashcorp/spotifyquiz
    def test_request_authorized_token_bad_refresh_token(self):
        """
        request_authorized_token() needs a valid refresh token from the session
        to get an access token. If the refresh token is invalid, the function
        should fail. The refresh token should be unchanged and the
        access token should still be None.
        """
        session = self.client.session
        spotify._set_refresh_token(session, 'bad_code')
        spotify._set_user_id(session, 'user_id')

        spotify._request_authorized_token(session)

        self.assertIsNone(session.get(spotify.AUTH_ACCESS_TOKEN))
        self.assertIs(session.get(spotify.REFRESH_TOKEN), 'bad_code')