Exemple #1
0
 def test_category_of_item(self):
     root = RootProjectTreeItem()
     category = CategoryProjectTreeItem("category", "category description")
     root.add_child(category)
     model = ProjectItemModel(self.toolbox, root)
     self.assertEqual(model.category_of_item("nonexistent item"), None)
     project_item = ProjectItem("item", "item description", 0.0, 0.0,
                                self.toolbox.project(), self.toolbox)
     item = LeafProjectTreeItem(project_item, self.toolbox)
     category.add_child(item)
     found_category = model.category_of_item("item")
     self.assertEqual(found_category.name, category.name)
 def _category_item():
     """Set up toolbox."""
     toolbox = create_toolboxui_with_project()
     properties_ui = ViewPropertiesWidget(toolbox).ui
     item = CategoryProjectTreeItem("category item", "A category tree item",
                                    View, ViewIcon, AddProjectItemWidget,
                                    properties_ui)
     return toolbox, item
Exemple #3
0
 def test_insert_item_category_item(self):
     root = RootProjectTreeItem()
     model = ProjectItemModel(self.toolbox, root)
     category = CategoryProjectTreeItem("category", "category description")
     model.insert_item(category)
     self.assertEqual(model.rowCount(), 1)
     self.assertEqual(model.n_items(), 0)
     category_index = model.find_category("category")
     self.assertTrue(category_index.isValid())
     self.assertEqual(category_index.row(), 0)
     self.assertEqual(category_index.column(), 0)
     self.assertEqual(model.data(category_index, Qt.DisplayRole),
                      "category")
 def test_set_leaf_item_name(self):
     root = RootProjectTreeItem()
     model = ProjectItemModel(root)
     category = CategoryProjectTreeItem("category", "category description")
     model.insert_item(category)
     category_index = model.find_category("category")
     project_item = ProjectItem("item", "item description", 0.0, 0.0,
                                self.toolbox.project())
     leaf = LeafProjectTreeItem(project_item, self.toolbox)
     model.insert_item(leaf, category_index)
     leaf_index = model.find_item("item")
     model.set_leaf_item_name(leaf_index, "new view item name")
     leaf_item = model.get_item("new view item name")
     self.assertIsNotNone(leaf_item)
Exemple #5
0
 def test_insert_item_leaf_item(self):
     root = RootProjectTreeItem()
     model = ProjectItemModel(self.toolbox, root)
     category = CategoryProjectTreeItem("category", "category description")
     model.insert_item(category)
     category_index = model.find_category("category")
     mock_project_item = NonCallableMagicMock()
     mock_project_item.name = "project item"
     mock_project_item.description = "project item description"
     leaf = LeafProjectTreeItem(mock_project_item, self.toolbox)
     model.insert_item(leaf, category_index)
     self.assertEqual(model.rowCount(), 1)
     self.assertEqual(model.rowCount(category_index), 1)
     self.assertEqual(model.n_items(), 1)
     self.assertEqual(model.items("category"), [leaf])
Exemple #6
0
 def _category_item():
     """Set up toolbox."""
     toolbox = create_toolboxui_with_project()
     item = CategoryProjectTreeItem("category item", "A category tree item")
     return toolbox, item