def setup(self): """ - root [main, folder] - child1 [loc: 1, main, article] - child2 [main, folder] - root2 [main, folder] - child3 [main, article] - child4 [main, folder] path count: 12 content count: 6 article count: 2 folder count: 4 """ super().setup() self.root = get_folder(name='r1') self.child1 = get_article(self.root, name='a1') self.child2 = get_folder(self.child1, name='a2') self.root2 = get_folder(name='r2') self.child3 = get_article(self.root2, name='a3') self.child4 = get_folder(self.child3, name='a4') self.s.add_all([self.root, self.child1, self.child2]) self.s.add_all([self.root2, self.child3, self.child4]) self.s.commit() self.path_count = self.s.query(Path).count() self.content_count = self.s.query(Content).count() self.article_count = self.s.query(Article).count() self.folder_count = self.s.query(Folder).count() self.fut = DeleteOperation(self.s)
def setup(self): super().setup() self.a1 = get_article(name='a1') self.a1.status_id = self.a1.status.TRASHED self.a2 = get_article(name='a2') self.s.add_all((self.a1, self.a2)) self.s.flush() self.query = Query(self.s, self.a1.__class__)
def test_slugs(self): f1 = get_folder(slug='Folder') a1 = get_article(parent=f1, slug='Article1') a2 = get_article(parent=a1, slug='Article2') slugs = a2.slugs assert 'Folder' == slugs[0] assert 'Article1' == slugs[1] assert 'Article2' == slugs[2]
def test_to(self): root = get_folder(name='f1') subject = get_article(root, name='a1') new_parent = get_folder(root, name='a2') self.s.add(root) self.s.commit() move = MoveOperation(self.s, subject) move.to(new_parent) assert subject.parent == new_parent
def test_lineage(self): root = get_folder(name='f1') child1 = get_article(parent=root, name='c1') child2 = get_folder(parent=child1, name='c2') ancestors = child2.lineage assert len(ancestors) == 3 assert ancestors[0] == root assert ancestors[1] == child1 assert ancestors[2] == child2
def setup(self): super().setup() # - root # - - article 1 # - - article 2 # - - folder 1 # - - - article 3 # - folder 2 # - - article 4 self.root = get_folder(name='root') self.a1 = get_article(parent=self.root, name='a1', title='a1 title') self.a2 = get_article(parent=self.root, name='a2') self.f1 = get_folder(parent=self.root, name='f1') self.f2 = get_folder(parent=self.root, name='f2') self.fa1 = get_article(parent=self.f1, name='fa1') self.fa2 = get_article(parent=self.f2, name='fa2') self.s.add(self.root) self.s.commit() self.query = Query(self.s, self.root)
def test_create_new(self): article = get_article(name='testing') assert article.name == 'testing'
def test_parent(self): article1 = get_article() article2 = get_article(parent=article1, name='a2') assert article2.parent == article1