def test_add_item_with_select_with_filter_middle(self): new_item = ['b1'] model = FilterCheckboxListModel() model.set_list(self.data) model.set_filter('b') with mock.patch("tabularview_models.FilterCheckboxListModel.beginInsertRows") as bir, \ mock.patch("tabularview_models.FilterCheckboxListModel.endInsertRows") as eir, \ mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc: model.add_item(new_item) self.assertEqual(model._filter_index, [3,4,5,6]) self.assertEqual(model.data(model.index(1 + 2, 0)), new_item[0])
def test_add_item_with_select_with_filter_last(self): new_item = ['bbbb'] model = FilterCheckboxListModel() model.set_list(self.data) model.set_filter('b') with mock.patch("tabularview_models.FilterCheckboxListModel.beginInsertRows") as bir, \ mock.patch("tabularview_models.FilterCheckboxListModel.endInsertRows") as eir, \ mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc: model.add_item(new_item) self.assertEqual(model._data, sorted(self.data + new_item)) self.assertEqual(model._data_set, set(self.data + new_item)) self.assertEqual(model._filter_index, [3,4,5,6]) self.assertEqual(model._selected_filtered, set(self.data[3:] + new_item)) self.assertEqual(model.data(model.index(3 + 2, 0)), new_item[0])
def test_get_data_when_filtered(self): model = FilterCheckboxListModel() model.set_list(self.data) model.set_filter('b') self.assertEqual(model.data(model.index(2,0)), 'b')
def test_add_to_selection_when_filter(self): model = FilterCheckboxListModel() model.set_list(self.data) model.set_filter('b') self.assertFalse(model._add_to_selection) self.assertFalse(model.data(model.index(1,0), Qt.CheckStateRole))