def test_post_list_can_save_POST_request(self): a_user = User() a_user.save() a_post = Post() a_post.author_id = 1 a_post.save() request = HttpRequest() request.method = "POST" request.POST["comment_text"] = "A new Comment" response = post_list(request) self.assertIn("A new Comment", response.content.decode()) expected_html = render_to_string("news/post_list.html", {"new_item_text": "A new Comment"}) self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = post_list(request) self.assertIn(b"<html>", response.content) self.assertIn(b"<title>Famia Nkansa</title>", response.content) self.assertIn(b"</html>", response.content)