Example #1
0
class PostDetailTests(HtmlTestCaseMixin, TestCase):

    def setUp(self):
        self.parent = CategoryFactory()
        child = CategoryFactory(parent=self.parent)
        self.category = CategoryFactory(parent=child)
        self.post = PostFactory(rubric=self.category)

    def test_detail(self):
        response = client.get(self.post.get_absolute_url())
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'posts/detail.html')
        self.assertIn('object', response.context)
        self.assertEqual(len(response.context['menu_items']), 1)

    def test_meta_data(self):
        response = client.get(self.post.get_absolute_url())
        self.assertEqual(response.status_code, 200)
        self.assertMetaDataIn(response.content)
        self.assertH1(response.content)
Example #2
0
 def test_get_absolute_url(self):
     parent = CategoryFactory(slug='aaa')
     child = CategoryFactory(parent=parent, slug='bbb')
     child2 = CategoryFactory(parent=child, slug='ccc')
     post = PostFactory(rubric=child2, slug='ddd', id='12')
     self.assertEqual(post.get_absolute_url(), '/bbb/ccc/ddd-12.html')