Exemple #1
0
    def test_blog_post_index_filters_by_tag(self):
        blog_post_index_page = BlogPostIndexFactory.create()
        tagged_post = BlogPostFactory.create(tags=["foo"], parent=blog_post_index_page)
        untagged_post = BlogPostFactory.create(
            tags=["bar"], parent=blog_post_index_page
        )

        rv = client.get(blog_post_index_page.url + "tag/foo/")

        assert tagged_post.title in str(rv.content)
        assert untagged_post.title not in str(rv.content)
Exemple #2
0
    def test_blog_post_index_page_has_pagination(self):
        blog_post_index_page = BlogPostIndexFactory.create()
        BlogPostFactory.create_batch(60, parent=blog_post_index_page)

        rv = client.get(blog_post_index_page.url)
        assert rv.status_code == 200

        assert '<a class="current" href="/blog/page/1">1</a>' in str(rv.content)
        assert '<a href="/blog/page/2">2</a>' in str(rv.content)
        assert '<a href="/blog/page/3">3</a>' in str(rv.content)
        assert '<a href="/blog/page/4">4</a>' in str(rv.content)
        assert '<a href="/blog/page/5">5</a>' in str(rv.content)
        assert "<li>...</li>" in str(rv.content)
        assert '<a href="/blog/page/2">Next</a>' in str(rv.content)
Exemple #3
0
    def test_author_is_visible(self):
        blog_post = BlogPostFactory.create(
            authors=[AuthorFactory(name="Jane Smith")])

        rv = client.get(blog_post.url)

        assert ("Jane Smith") in str(rv.content)
Exemple #4
0
    def test_blog_post_title_is_visible(self):
        """Test that the blog post title and content is visible in the template
        """
        blog_post = BlogPostFactory.create()
        rv = client.get(blog_post.url)

        assert blog_post.title in str(rv.content)
Exemple #5
0
    def test_blog_post_tags_are_visible(self):
        """Test that a blog post's tags are visible on the blog post template
        """
        blog_post = BlogPostFactory.create(tags=("foo", "bar", "baz"))

        rv = client.get(blog_post.url)

        assert "foo" in str(rv.content)
        assert "bar" in str(rv.content)
        assert "baz" in str(rv.content)
Exemple #6
0
    def test_blog_post_index_lists_child_posts(self):
        blog_post_index_page = BlogPostIndexFactory.create()
        blog_posts = BlogPostFactory.create_batch(10, parent=blog_post_index_page)

        page1 = client.get(blog_post_index_page.url)
        assert page1.status_code == 200

        page2 = client.get(blog_post_index_page.url + "page/2/")
        assert page2.status_code == 200

        for blog_post in blog_posts[:5]:
            assert blog_post.title in str(page1.content)

        for blog_post in blog_posts[5:10]:
            assert blog_post.title in str(page2.content)
Exemple #7
0
 def test_blog_post_has_the_correct_title(self):
     """Test that the blog post has the expected title
     """
     blog_post = BlogPostFactory.create(title="Here is a blog post")
     assert blog_post.title == "Here is a blog post"
Exemple #8
0
 def test_blog_post_gets_created(self):
     """Test that we have a blog post created by the fixture
     """
     blog_post = BlogPostFactory.create()
     assert blog_post is not None