fix: Test client initialization with explicit API key

The test_client_initialization test was failing in CI because it tried
to create a Hanzo() client without an API key. Fixed by:
- Providing a dummy test API key for unit testing (tests instantiation)
- Adding separate test for env-based initialization that's skipped when
  HANZO_API_KEY is not set
This commit is contained in:
2025-12-09 19:37:09 -08:00
parent 44d00ae148
commit 207aace6f0
+14 -1
View File
@@ -73,7 +73,20 @@ class TestBasicClient:
"""Test basic Hanzo client functionality."""
def test_client_initialization(self):
"""Test client can be initialized."""
"""Test client can be initialized with API key."""
from hanzoai import Hanzo
# Use a dummy API key for testing - this only tests client instantiation
# not actual API connectivity
client = Hanzo(api_key="test-api-key-for-unit-tests")
assert client is not None
@pytest.mark.skipif(
not os.environ.get("HANZO_API_KEY"),
reason="HANZO_API_KEY not set"
)
def test_client_initialization_from_env(self):
"""Test client can be initialized from environment."""
from hanzoai import Hanzo
client = Hanzo()