def test_get(self, req, comment): comment.add(req) second = ArticleComment(comment.id) second.object_id = comment.object_id second.get(req) for attr in ('id', 'object_id', 'author', 'author_id', 'create_date', 'title', 'body', 'data'): assert getattr(comment, attr) == getattr(second, attr), attr
def comment(article, request=None): comment = ArticleComment() form = Form((('article_id', article.id), ('author', 'Ondřej Tůma'), ('title', u'Title'), ('perex', u'perex'), ('body', u'body'), ('state', 0))) comment.bind(form, user_agent='py.test', ip='127.0.0.1') return comment
def test_tree(self, req, article): c1 = comment(article) c1.add(req) assert c1.id == '1' c2 = comment(article) c2.add(req) assert c2.id == '2' c11 = comment(article) c11.add(req, '1') assert c11.id == '1.1' c12 = comment(article) c12.add(req, '1') assert c12.id == '1.2' c21 = comment(article) c21.add(req, '2') assert c21.id == '2.1' c121 = comment(article) c121.add(req, '1.2') assert c121.id == '1.2.1' discussion = ArticleComment.list(req, article.id, Pager()) cids = list(c.id for c in discussion) for it in (c1.id, c11.id, c12.id, c121.id, c2.id, c21.id): assert it in cids