def test_add_item_without_select_without_filter(self): new_item = ['aaaa'] model = FilterCheckboxListModel() model.set_list(self.data) 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, selected=False) self.assertFalse(model._all_selected)
def test_add_item_with_select_without_filter(self): new_item = ['aaaa'] model = FilterCheckboxListModel() model.set_list(self.data) 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))
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])