def test_show_items_after_enter_msg(self): request = HttpRequest() request.method = 'post' request.POST['item_text'] = 'A new list item' response = home(request) self.assertIn('A new list item', response.content.decode()) expect_html = render_to_string('html/home.html', {'l'})
def test_returns_correct_html(self): req = HttpRequest() res = home(req) self.assertEqual(res.status_code, 200) self.assertTrue(res.content.strip().startswith(b'<html>')) self.assertIn(b'<title>ToDo lists</title>', res.content) self.assertTrue(res.content.strip().endswith(b'</html>'))
def test_response_html(self): # create HttpRequest object. request = HttpRequest() # Pass request to browser response = home(request) # assert the content expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html)
def display_mutiItems(self): Item.objects.create(text='itemey 1') Item.objects.create(text='itemey 2') request = HttpRequest() response = home(request) self.assertIn('itemey 1', response.content.decode()) self.assertIn('itemey 2', response.content.decode())
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home(request) # response_content = response.content # if type(response_content) != str: # response_content = str(response.content)[2:-1] self.assertTrue(response.content.startswith(b'<html>')) self.assertIn(b'<title>To-Do Lists</title>', response.content) self.assertTrue(response.content.endswith(b'</html>'))
def test_home_page_return_correct_html(self): request = HttpRequest() response = home(request) content = render_to_string('html/home.html') self.assertIn(content, response.content.decode())
def test_home_only_save(self): request = HttpRequest() home(request) self.assertEqual(Item.objects.count(), 0)