Ejemplo n.º 1
0
    def test_print_posts(self):
        blog = Blog('Test', 'Test Author')
        blog_project.app.blogs = {'Test': blog}
        blog.create_new_post('Test Title', 'Test Content')
        with patch('blog_project.app.print_post') as mocked_print_post:
            blog_project.app.print_posts(blog)

            mocked_print_post.assert_called_with(blog.posts[0])
    def test_create_json_blog(self):
        new_blog = Blog ("Ian Kowalsky", "Cookies Time")
        new_blog.create_new_post("Something delicious", "We love sweets and so on")
        expected_json = {
            "author" : "Ian Kowalsky",
            "title" : "Cookies Time",
            "posts" : [{
                "title" : "Something delicious",
                "content" : "We love sweets and so on" }]
        }

        self.assertDictEqual(expected_json, new_blog.create_json())
    def test_create_new_post_verify_post_content(self):
        blog_with_post = Blog ("Ian Kowalsky", "Cookies Time")
        blog_with_post.create_new_post("Something delicious", "We love sweets and so on")

        self.assertEqual("We love sweets and so on", blog_with_post.posts[0].content)