Skip to content

Commit e8fbddc

Browse files
committed
test(semantic-layer): strengthen date resample regression assertions
Narrow semantic filters before checking temporal bounds so full-tree mypy can verify the assertions. Snapshot empty results and assert post-processing is skipped so removing the empty guard fails the regression test. Addresses review threads 4639084179 and 4639084190 on #46378.
1 parent d7e74f9 commit e8fbddc

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎tests/unit_tests/semantic_layers/date_result_test.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ def test_semantic_date_resample_empty_skips_post_processing(
198198
timedelta(0),
199199
_ViewMetadata(metrics=(), dimensions=()),
200200
)
201+
expected: pd.DataFrame = result.df.copy()
201202
mocker.patch("superset.semantic_layers.models.get_results", return_value=result)
202-
pd.testing.assert_frame_equal(SemanticView().get_query_result(query).df, result.df)
203+
post_processing: MagicMock = mocker.spy(query, "exec_post_processing")
204+
pd.testing.assert_frame_equal(SemanticView().get_query_result(query).df, expected)
205+
post_processing.assert_not_called()
203206

204207

205208
@pytest.mark.parametrize("resampling", [False, True])

‎tests/unit_tests/semantic_layers/mapper_test.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,12 @@ def test_date_resample_fills_gaps_through_get_results(
22222222
main_query: SemanticQuery = mock_datasource.implementation.get_table.call_args_list[
22232223
0
22242224
].args[0]
2225-
assert {(item.operator, item.value) for item in main_query.filters} == {
2225+
assert main_query.filters is not None
2226+
conditions: list[Filter] = [
2227+
item for item in main_query.filters if isinstance(item, Filter)
2228+
]
2229+
assert len(conditions) == len(main_query.filters)
2230+
assert {(item.operator, item.value) for item in conditions} == {
22262231
(Operator.GREATER_THAN_OR_EQUAL, datetime(2026, 1, 5)),
22272232
(Operator.LESS_THAN, datetime(2026, 1, 8)),
22282233
}

0 commit comments

Comments
 (0)