fix(dwh): align adapter sampling contract
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
from dataclasses import FrozenInstanceError
|
||||
|
||||
import pytest
|
||||
|
||||
from tht.execute import ExecResult, PlanSummary
|
||||
from tht.mschema.models import PhysicalSchema
|
||||
from tht.ports.dwh import (
|
||||
DwhAdapter,
|
||||
DwhCapabilities,
|
||||
DwhHealth,
|
||||
DistinctValues,
|
||||
UnsupportedCapability,
|
||||
)
|
||||
|
||||
@@ -17,7 +22,7 @@ class FakeDwhAdapter:
|
||||
def introspect(self) -> PhysicalSchema:
|
||||
raise NotImplementedError
|
||||
|
||||
def run_query(self, sql: str, *, limit: int | None = None) -> ExecResult:
|
||||
def run_query(self, sql: str, *, limit: int) -> ExecResult:
|
||||
raise NotImplementedError
|
||||
|
||||
def explain(self, sql: str) -> PlanSummary:
|
||||
@@ -26,7 +31,7 @@ class FakeDwhAdapter:
|
||||
def sample_column(self, table: str, column: str, *, limit: int) -> list[object]:
|
||||
raise NotImplementedError
|
||||
|
||||
def distinct_values(self, table: str, column: str) -> list[object]:
|
||||
def distinct_values(self, table: str, column: str) -> DistinctValues:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -45,3 +50,13 @@ def test_contract_types_are_public_and_capabilities_are_immutable():
|
||||
assert capabilities.sampling is True
|
||||
assert capabilities.distinct_values is True
|
||||
assert issubclass(UnsupportedCapability, Exception)
|
||||
with pytest.raises(FrozenInstanceError):
|
||||
capabilities.explain = False
|
||||
|
||||
|
||||
def test_all_contract_types_are_exported_from_public_package():
|
||||
from tht.ports import DistinctValues as PublicDistinctValues
|
||||
|
||||
result = PublicDistinctValues(values=["a"], truncated=True)
|
||||
assert result.values == ["a"]
|
||||
assert result.truncated is True
|
||||
|
||||
Reference in New Issue
Block a user