Skip to content

Commit 7d3a146

Browse files
committed
Fix bug uncovered by testing changes for retry decorators
1 parent 449a5f7 commit 7d3a146

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/folioclient/FolioClient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,11 @@ def _clear_single_cached_property(self, prop_name: str) -> None:
642642
prop_name (str): Name of the property to clear.
643643
"""
644644
# Verify it's actually a cached property before deleting
645+
# Use __dict__ to check if value is cached without triggering property evaluation
645646
if (
646647
hasattr(self.__class__, prop_name)
647648
and self._is_cached_property(prop_name)
648-
and hasattr(self, prop_name)
649+
and prop_name in self.__dict__
649650
):
650651
delattr(self, prop_name)
651652

tests/test_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ def folio_auth_patcher():
2525
# Instead of trying to mock the whole class, patch the problematic methods
2626
# This is more reliable as it doesn't deal with import timing issues
2727
from datetime import datetime, timezone, timedelta
28+
import httpx
2829

2930
mock_token = Mock()
3031
mock_token.auth_token = "test-token"
3132
mock_token.refresh_token = "test-refresh-token"
3233
# Set expires_at to a future datetime to avoid expiration issues
3334
mock_token.expires_at = datetime.now(timezone.utc) + timedelta(hours=1)
35+
# Mock cookies as an httpx.Cookies object (which is iterable)
36+
mock_token.cookies = httpx.Cookies()
37+
mock_token.cookies.set("folioAccessToken", "test-token")
38+
mock_token.cookies.set("folioRefreshToken", "test-refresh-token")
3439

3540
with patch('folioclient._httpx.FolioAuth._do_sync_auth', return_value=mock_token), \
3641
patch('folioclient._httpx.FolioAuth._token_is_expiring', return_value=False):

0 commit comments

Comments
 (0)