Skip to content

Commit

Permalink
Fix issue with filtering and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Sep 11, 2024
1 parent 671f58e commit ed26022
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 5 additions & 9 deletions src/ert/gui/tools/plot/data_type_proxy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion tests/unit_tests/gui/plottery/test_plotting_of_snake_oil.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,21 @@ 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):
cb.setChecked(i == u)

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()

0 comments on commit ed26022

Please sign in to comment.