def get_context_data(self, **kwargs): context = super(BlogView, self).get_context_data(**kwargs) default_blog = Blog.query().get() context['blog'] = default_blog if default_blog: context['posts'] = Blog.get_all_posts(default_blog.key.id()) return context
def test_post_create(self): """ create a post """ res = self.c.post('/post/{0}'.format(self.blog_id), {'title': 'First Post', 'synopsis': 'Post Extract', 'content': 'Post Content', 'tags': ['tag1', 'tag2', 'tag3']}) self.assertEqual(len(Blog.get_all_posts(self.blog_id)), 2)
def test_post_delte(self): """ we can delete """ res = self.c.delete('/post/delete/{0}'.format(self.post_id)) self.assertEqual(len(Blog.get_all_posts(self.blog_id)), 0)