From ed260226971abd47aa0e4629bb97c4c669bd7500 Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Wed, 11 Sep 2024 13:31:13 +0200 Subject: [PATCH] Fix issue with filtering and tests --- src/ert/gui/tools/plot/data_type_proxy_model.py | 14 +++++--------- .../gui/plottery/test_plotting_of_snake_oil.py | 9 ++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ert/gui/tools/plot/data_type_proxy_model.py b/src/ert/gui/tools/plot/data_type_proxy_model.py index fec4e242803..0b9182f55db 100644 --- a/src/ert/gui/tools/plot/data_type_proxy_model.py +++ b/src/ert/gui/tools/plot/data_type_proxy_model.py @@ -26,16 +26,12 @@ def filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) -> bool: for meta_key, values in self._metadata_filters.items(): for value, visible in values.items(): - if ( - ( - not visible - and meta_key in key.metadata - and key.metadata[meta_key] == value - ) - or not visible - and key.history_vector + if not visible and ( + (meta_key in key.metadata and key.metadata[meta_key] == value) + or (value == "History Vector" and key.history_vector) ): - show = False + return False + return show def sourceModel(self) -> DataTypeKeysListModel: diff --git a/tests/unit_tests/gui/plottery/test_plotting_of_snake_oil.py b/tests/unit_tests/gui/plottery/test_plotting_of_snake_oil.py index 02c554afa90..f4fc1ecd47b 100644 --- a/tests/unit_tests/gui/plottery/test_plotting_of_snake_oil.py +++ b/tests/unit_tests/gui/plottery/test_plotting_of_snake_oil.py @@ -142,9 +142,11 @@ def test_that_all_plotter_filter_boxes_yield_expected_filter_results( key_list = plot_window.findChild(DataTypeKeysWidget).data_type_keys_widget item_count = [3, 10, 45] - assert key_list.model().rowCount() == sum(item_count) + cbs = plot_window.findChildren(QCheckBox, "FilterCheckBox") + history_filter = cbs[3] + cbs = cbs[0:3] for i in range(len(item_count)): for u, cb in enumerate(cbs): @@ -152,4 +154,9 @@ def test_that_all_plotter_filter_boxes_yield_expected_filter_results( assert key_list.model().rowCount() in item_count + # test history vector filtering + assert key_list.model().rowCount() == 45 + history_filter.setChecked(False) + assert key_list.model().rowCount() == 24 + plot_window.close()