def test_gets_from_cache_path(self, opener,
                                  is_token_expired, refresh_access_token):
        """Test that the token is retrieved from the cache path."""
        scope = "playlist-modify-private"
        path = ".cache-username"
        tok = _make_fake_token(1, 1, scope)
        token_file = _token_file(json.dumps(tok, ensure_ascii=False))
        opener.return_value = token_file
        opener.return_value.__enter__ = mock.Mock(return_value=token_file)
        opener.return_value.__exit__ = mock.Mock(return_value=False)
        is_token_expired.return_value = False

        spot = _make_oauth(scope, path)
        cached_tok = spot.validate_token(spot.cache_handler.get_cached_token())
        cached_tok_legacy = spot.get_cached_token()

        opener.assert_called_with(path, encoding='utf-8')
        self.assertIsNotNone(cached_tok)
        self.assertIsNotNone(cached_tok_legacy)
        self.assertEqual(refresh_access_token.call_count, 0)
Test that the token is retrieved from the cache path.
tests/unit/test_oauth.py