def test_create_rename_delete(self): ti1 = TreeItem(title='new_root_item', tree=self.t1) ti1.save(force_insert=True) self.assertIsNotNone(ti1.id) self.assertEqual(ti1.title, 'new_root_item') ti1.title = 'not_new_root_item' ti1.save(force_update=True) self.assertEqual(ti1.title, 'not_new_root_item') ti1.delete() self.assertIsNone(ti1.id)
def setUpClass(cls): cls.sitetree = SiteTree() t1 = Tree(alias='tree1') t1.save(force_insert=True) t1_root = TreeItem(title='root', tree=t1, url='/') t1_root.save(force_insert=True) t1_root_child1 = TreeItem(title='child1', tree=t1, parent=t1_root, url='/about/') t1_root_child1.save(force_insert=True) t1_root_child2 = TreeItem(title='child2', tree=t1, parent=t1_root, url='articles_list', urlaspattern=True) t1_root_child2.save(force_insert=True) t1_root_child2_sub1 = TreeItem(title='subchild1', tree=t1, parent=t1_root_child2, url='articles_detailed art_id', urlaspattern=True) t1_root_child2_sub1.save(force_insert=True) t1_root_child2_sub2 = TreeItem(title='subchild2', tree=t1, parent=t1_root_child2, url='/not_articles/10/') t1_root_child2_sub2.save(force_insert=True) t2 = Tree(alias='tree2') t2.save(force_insert=True) t2_root1 = TreeItem(title='{{ t2_root1_title }}', tree=t2, url='/') t2_root1.save(force_insert=True) t2_root2 = TreeItem(title='put {{ t2_root2_title }} inside', tree=t2, url='/sub/') t2_root2.save(force_insert=True) t2_root3 = TreeItem(title='for logged in only', tree=t2, url='/some/', access_loggedin=True) t2_root3.save(force_insert=True) cls.t1 = t1 cls.t1_root = t1_root cls.t1_root_child1 = t1_root_child1 cls.t1_root_child2 = t1_root_child2 cls.t1_root_child2_sub1 = t1_root_child2_sub1 cls.t1_root_child2_sub2 = t1_root_child2_sub2 cls.t2 = t2 cls.t2_root1 = t2_root1 cls.t2_root2 = t2_root2 cls.t2_root3 = t2_root3
def setUpClass(cls): cls.sitetree = SiteTree() t1 = Tree(alias='tree3') t1.save(force_insert=True) t1_root = TreeItem(title='root', tree=t1, url='/', hidden=True) t1_root.save(force_insert=True) t1_root_child1 = TreeItem(title='child1', tree=t1, parent=t1_root, url='/0/', access_loggedin=True) t1_root_child1.save(force_insert=True) t1_root_child2 = TreeItem(title='child2', tree=t1, parent=t1_root, url='/1/', inmenu=True, hidden=True) t1_root_child2.save(force_insert=True) t1_root_child3 = TreeItem(title='child3', tree=t1, parent=t1_root, url='/2/', inmenu=False) t1_root_child3.save(force_insert=True) t1_root_child4 = TreeItem(title='child4', tree=t1, parent=t1_root, url='/3/', hidden=True) t1_root_child4.save(force_insert=True) t1_root_child5 = TreeItem(title='child5', tree=t1, parent=t1_root, url='/4/', inmenu=True, hidden=True) t1_root_child5.save(force_insert=True) t2 = Tree(alias='tree3_en') t2.save(force_insert=True) t2_root = TreeItem(title='root_en', tree=t2, url='/') t2_root.save(force_insert=True) t2_root_child1 = TreeItem(title='child1_en', tree=t2, parent=t2_root, url='/0_en/') t2_root_child1.save(force_insert=True) t2_root_child2 = TreeItem(title='child2_en', tree=t2, parent=t2_root, url='/1_en/') t2_root_child2.save(force_insert=True) cls.t1 = t1 cls.t1_root = t1_root cls.t1_root_child1 = t1_root_child1 cls.t1_root_child2 = t1_root_child2 cls.t1_root_child2 = t1_root_child3 cls.t1_root_child2 = t1_root_child4 cls.t1_root_child2 = t1_root_child5 cls.t2_root = t2_root
def test_no_tree(self): ti = TreeItem(title='notree_item') self.assertRaises(Exception, ti.save)