Example #1
0
 def test_click_select_all_when_not_all_selected(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)
         index = model.index(0, 0)
         model.click_index(index)
     self.assertTrue(model._all_selected)
     self.assertEqual(model._selected, set(self.data))
Example #2
0
 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)
Example #3
0
 def test_click_select_empty_when_selected(self):
     model = FilterCheckboxListModel()
     model.set_list(self.data)
     with mock.patch("tabularview_models.FilterCheckboxListModel.dataChanged") as dc:
         index = model.index(1, 0)
         model.click_index(index)
     self.assertFalse(model._empty_selected)
     self.assertFalse(model._all_selected)
Example #4
0
 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)
Example #5
0
 def test_click_selected_item_when_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)
     self.assertEqual(model._selected_filtered, set(self.data[4:]))
     self.assertFalse(model._all_selected)
Example #6
0
 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])
Example #7
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])
Example #8
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')
Example #9
0
 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))