def test_click_selected_item(self): model = FilterCheckboxListModel() model.set_list(self.data) with mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc: index = model.index(2, 0) model.click_index(index) self.assertEqual(model._selected, set(self.data).difference(set(['a']))) self.assertFalse(model._all_selected)
def test_click_select_all_when_all_selected(self): model = FilterCheckboxListModel() model.set_list(self.data) with mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc: index = model.index(0, 0) model.click_index(index) self.assertFalse(model._all_selected) self.assertEqual(model._selected, set())
def test_click_unselected_item(self): model = FilterCheckboxListModel() model.set_list(self.data) model._selected.discard('a') with mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc: index = model.index(2, 0) model.click_index(index) self.assertEqual(model._selected, set(self.data)) self.assertTrue(model._all_selected)
def test_click_select_empty_when_unselected(self): model = FilterCheckboxListModel() model.set_list(self.data) model._empty_selected = False with mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc: index = model.index(1, 0) model.click_index(index) self.assertTrue(model._empty_selected) self.assertTrue(model._all_selected)
def test_click_select_all_when_all_not_selected_and_filtered(self): model = FilterCheckboxListModel() model.set_list(self.data) model.set_filter('b') with mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc: index = model.index(2, 0) model.click_index(index) index = model.index(0, 0) model.click_index(index) self.assertTrue(model._all_selected) self.assertEqual(model._selected, set(self.data)) self.assertEqual(model._selected_filtered, set(self.data[3:]))