Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/format_bench/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def validate(self) -> None:
if self.kind is WorkloadKind.FILTER:
if (
not self.column
or self.operator is None
or not is_comparison_operator(self.operator)
or self.value is None
):
raise ValueError(f"filter workload {self.operation} needs a supported predicate")
Expand Down
15 changes: 15 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
robustness_verdict,
transition,
)
from format_bench.workload_contract import ComparisonOperator


def test_lifecycle_accepts_the_public_contract() -> None:
Expand Down Expand Up @@ -125,6 +126,20 @@ def test_workload_spec_rejects_incomplete_predicates() -> None:
)


def test_workload_spec_rejects_unsupported_direct_operator() -> None:
unsupported = cast(ComparisonOperator, "contains")
spec = WorkloadSpec(
"filter",
WorkloadKind.FILTER,
column="value",
operator=unsupported,
value="needle",
)

with pytest.raises(ValueError, match="supported predicate"):
spec.validate()


@pytest.mark.parametrize("value", [1.5, "1.5"])
def test_workload_spec_rejects_fractional_integer_fields(value: object) -> None:
with pytest.raises(ValueError, match="must be an integer"):
Expand Down
Loading