Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(database): migrate 2 credential_store TTL tests to freezegun (#4235)

LearningCircuit057a4ceab855
diff --git a/tests/database/test_credential_store_behavior.py b/tests/database/test_credential_store_behavior.py
index 4abe485945..eb4a489aca 100644
--- a/tests/database/test_credential_store_behavior.py
+++ b/tests/database/test_credential_store_behavior.py
@@ -4,7 +4,7 @@ Behavioral tests for credential_store_base and temp_auth modules.
Tests the credential storage with TTL expiration.
"""
-import time
+from freezegun import freeze_time
class TestCredentialStoreBaseInit:
@@ -127,13 +127,15 @@ class TestCredentialStoreTTL:
"""Credentials expire after TTL."""
from local_deep_research.database.temp_auth import TemporaryAuthStore
- # Use very short TTL for testing
- store = TemporaryAuthStore(ttl_seconds=1)
- token = store.store_auth("testuser", "testpass")
- # Wait for expiration
- time.sleep(1.5) # allow: unmarked-sleep
- result = store.retrieve_auth(token)
- assert result is None
+ # SUT (credential_store_base) compares time.time() to
+ # entry["expires_at"], so freezegun can mock the clock fully.
+ with freeze_time("2026-01-01 00:00:00") as frozen:
+ store = TemporaryAuthStore(ttl_seconds=1)
+ token = store.store_auth("testuser", "testpass")
+ # Advance past expiration
+ frozen.tick(1.5)
+ result = store.retrieve_auth(token)
+ assert result is None
def test_credentials_valid_before_ttl(self):
"""Credentials are valid before TTL."""
@@ -302,14 +304,15 @@ class TestCredentialStoreCleanup:
"""Expired entries are cleaned when storing new credentials."""
from local_deep_research.database.temp_auth import TemporaryAuthStore
- store = TemporaryAuthStore(ttl_seconds=1)
- token1 = store.store_auth("user1", "pass1")
- time.sleep(1.5) # allow: unmarked-sleep # Wait for expiration
- # Storing new entry should trigger cleanup
- store.store_auth("user2", "pass2")
- # token1 should be expired and cleaned
- result = store.peek_auth(token1)
- assert result is None
+ with freeze_time("2026-01-01 00:00:00") as frozen:
+ store = TemporaryAuthStore(ttl_seconds=1)
+ token1 = store.store_auth("user1", "pass1")
+ frozen.tick(1.5) # Advance past expiration
+ # Storing new entry should trigger cleanup
+ store.store_auth("user2", "pass2")
+ # token1 should be expired and cleaned
+ result = store.peek_auth(token1)
+ assert result is None
class TestCredentialStoreEdgeCases: