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 4a82a8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/ert/gui/tools/plot/data_type_proxy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ 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
not visible
and (
meta_key in key.metadata and key.metadata[meta_key] == value
)
or not visible
and key.history_vector
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 4a82a8c

Please sign in to comment.