Add config and client injection with test reorganization.
Introduce typed config objects, optional adapter injection, and .env loading to simplify testing while preserving env-based defaults for production usage. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
co-authored by
Cursor
parent
366831ac52
commit
7991dabdbc
@@ -0,0 +1,54 @@
|
||||
"""Unit tests for ConnectionAwareInterface."""
|
||||
|
||||
import pytest
|
||||
from python_repositories.interfaces.connection_aware_interface import (
|
||||
ConnectionAwareInterface,
|
||||
)
|
||||
|
||||
|
||||
def test_instantiation_fails_when_connect_not_implemented() -> None:
|
||||
"""Test that instantiation fails if connect is not implemented."""
|
||||
|
||||
class Incomplete(ConnectionAwareInterface):
|
||||
"""A class that does not implement connect."""
|
||||
|
||||
def disconnect(self) -> None:
|
||||
pass
|
||||
|
||||
def is_connected(self) -> bool:
|
||||
return False
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
_ = Incomplete() # type: ignore
|
||||
|
||||
|
||||
def test_instantiation_fails_when_disconnect_not_implemented() -> None:
|
||||
"""Test that instantiation fails if disconnect is not implemented."""
|
||||
|
||||
class Incomplete(ConnectionAwareInterface):
|
||||
"""A class that does not implement disconnect."""
|
||||
|
||||
def connect(self) -> None:
|
||||
pass
|
||||
|
||||
def is_connected(self) -> bool:
|
||||
return False
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
_ = Incomplete() # type: ignore
|
||||
|
||||
|
||||
def test_instantiation_fails_when_is_connected_not_implemented() -> None:
|
||||
"""Test that instantiation fails if is_connected is not implemented."""
|
||||
|
||||
class Incomplete(ConnectionAwareInterface):
|
||||
"""A class that does not implement is_connected."""
|
||||
|
||||
def connect(self) -> None:
|
||||
pass
|
||||
|
||||
def disconnect(self) -> None:
|
||||
pass
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
_ = Incomplete() # type: ignore
|
||||
Reference in New Issue
Block a user