Skip to content

Commit 9820e09

Browse files
myhoaiclaude
andcommitted
test(gooddata-eval): assert the verdict per malformed ranking filter
`assert ok == (len(errors) == 0)` was a tautology against an implementation that returns exactly `len(errors) == 0, errors`, so the case list could not fail: `attribute=[]` or `using=None` being accepted with ok=True would have gone unnoticed. Each case now carries its expected verdict. Confirmed non-vacuous by mutation: making a non-string `attribute` skip instead of erroring now fails the test, where before it passed. JIRA: QA-28615 risk: nonprod Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 483f4b4 commit 9820e09

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

packages/gooddata-eval/tests/test_scoring.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,25 @@ def test_ranking_attribute_omitted_does_not_mask_a_wrong_dimension():
132132

133133

134134
def test_validate_cross_references_never_raises_on_empty_or_none_uris():
135-
"""Each of these used to raise AttributeError/TypeError instead of returning a score."""
135+
"""Each of these used to raise AttributeError/TypeError instead of returning a score.
136+
137+
Every case carries its expected verdict: `attribute` is optional so None/"" are valid,
138+
while a non-string attribute or a missing/None `using` must be reported as an error.
139+
Asserting the verdict is what stops a malformed filter from silently passing as valid.
140+
"""
136141
cases = [
137-
{"type": "ranking_filter", "using": "m_sales", "top": 5, "attribute": None},
138-
{"type": "ranking_filter", "using": "m_sales", "top": 5, "attribute": ""},
139-
{"type": "ranking_filter", "using": "m_sales", "top": 5, "attribute": []},
140-
{"type": "ranking_filter", "using": None, "top": 5},
141-
{"type": "ranking_filter", "top": 5},
142+
({"type": "ranking_filter", "using": "m_sales", "top": 5, "attribute": None}, True),
143+
({"type": "ranking_filter", "using": "m_sales", "top": 5, "attribute": ""}, True),
144+
({"type": "ranking_filter", "using": "m_sales", "top": 5, "attribute": []}, False),
145+
({"type": "ranking_filter", "using": None, "top": 5}, False),
146+
({"type": "ranking_filter", "top": 5}, False),
142147
]
143-
for rank in cases:
148+
for rank, expected_ok in cases:
144149
viz = _viz(query={"fields": _M, "filter_by": {"f_rank": rank}})
145150
ok, errors = validate_cross_references(viz)
146151
assert isinstance(ok, bool) and isinstance(errors, list), rank
147-
assert ok == (len(errors) == 0), rank
152+
assert ok is expected_ok, rank
153+
assert bool(errors) is not expected_ok, rank
148154

149155

150156
def test_validate_cross_references_accepts_omitted_attribute_but_flags_missing_using():

0 commit comments

Comments
 (0)