diff --git a/src/format_bench/model.py b/src/format_bench/model.py index ed234ec..123659c 100644 --- a/src/format_bench/model.py +++ b/src/format_bench/model.py @@ -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") diff --git a/tests/test_model.py b/tests/test_model.py index d2dee23..caac697 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -19,6 +19,7 @@ robustness_verdict, transition, ) +from format_bench.workload_contract import ComparisonOperator def test_lifecycle_accepts_the_public_contract() -> None: @@ -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"):