def test_post_no_title(self): self.users_login('admin@localhost', is_admin=True) data = {'tagline': 'new_tagline'} self.client.post(self.url, data) self.assertEqual(Blog.get_unique().title, 'blog_title') self.assertEqual(Blog.get_unique().tagline, 'blog_tagline')
def get_context_data(self, *args, **kwargs): context = super(BlogMixin, self).get_context_data(*args, **kwargs) blog = Blog.get_unique() context.update({ 'blog': blog, 'active_user': users.get_current_user(), 'is_admin': users.is_current_user_admin() }) return context
def test_get_unique_one_blog(self): blog = Blog(key_name=settings.BLOG_KEY_NAME, title='blog_one') blog.put() result = Blog.get_unique() self.assertEqual(result.title, 'blog_one') self.assertEqual(result.tagline, None) self.assertEqual(Blog.all().count(), 1)
def test_post_valid(self): self.users_login('admin@localhost', is_admin=True) data = {'title': 'new_blog_title', 'tagline': 'new_tagline'} resp = self.client.post(self.url, data) blog = Blog.get_unique() self.assertRedirects(resp, reverse('index')) self.assertEqual(blog.title, 'new_blog_title') self.assertEqual(blog.tagline, 'new_tagline')
def get_object(self): return Blog.get_unique()
def test_get_unique_no_blogs(self): blog = Blog.get_unique() self.assertEqual(blog.key().name(), 'blog') self.assertEqual(blog.title, 'My Blog') self.assertEqual(blog.tagline, None) self.assertEqual(Blog.all().count(), 1)