def test_saves_to_cache_path(self, opener):
        """Test that the token is saved to the cache path."""
        scope = "playlist-modify-private"
        path = ".cache-username"
        tok = _make_fake_token(1, 1, scope)

        fi = _fake_file()
        opener.return_value = fi
        opener.return_value.__enter__ = mock.Mock(return_value=fi)
        opener.return_value.__exit__ = mock.Mock(return_value=False)

        spot = SpotifyOAuth("CLID", "CLISEC", "REDIR", "STATE", scope, path)
        spot.cache_handler.save_token_to_cache(tok)

        opener.assert_called_with(path, 'w', encoding='utf-8')
        self.assertTrue(fi.write.called)
Test that the token is saved to the cache path.
tests/unit/test_oauth.py