示例#1
0
    def test_post_delete(self):
        journal = self.addJournal()
        post = self.addPost()

        del journal[1]

        self.assertSequenceEqual(journal.keys(), [])
        self.assertEqual(DBSession.query(Post).count(), 0)
示例#2
0
    def test_post_add_comment_by_attributes(self):
        journal = self.addJournal()
        post = self.addPost()
        comment = self.addComment()

        self.assertEquals(len(post.comments), 1)
        comment2 = post.add_comment(text='Foo', user_id='bob', _flush=True)

        self.assertEquals(DBSession.query(Comment).count(), 2)
        self.assertEquals(len(post.comments), 2)
        self.assertSequenceEqual(post.keys(), [1, 2])
        self.assertSequenceEqual(post.values(), [comment, comment2])
        self.assertSequenceEqual(post.items(),
                                 [(1, comment), (2, comment2)])