def test_view_function(self): request = self.factory.get('/item/django-begginners') response = all_products(request) html = response.content.decode('utf8') self.assertIn('<title>Home</title>', html) self.assertTrue(html.startswith('\n<!DOCTYPE html>\n')) self.assertEqual(response.status_code, 200)
def test_homepage_html(self): request = HttpRequest() response = all_products(request) html = response.content.decode('utf8') self.assertIn('<title>Home</title>', html) self.assertTrue(html.startswith('\n<!DOCTYPE html>\n')) self.assertEqual(response.status_code, 200)
def test_homepage_url(self): request = HttpRequest() engine = import_module(settings.SESSION_ENGINE) request.session = engine.SessionStore() response = all_products(request) html = response.content.decode("utf8") self.assertNotIn("<title>Home</title>", html) self.assertTrue(html.startswith("\n<!DOCTYPE html>\n")) self.assertEqual(response.status_code, 200)
def test_homepage_html(self): """ Example: code validation, search HTML for text """ request = HttpRequest() response = all_products(request) html = response.content.decode('utf8') self.assertIn('<title>Home</title>', html) self.assertTrue(html.startswith('\n<!DOCTYPE html>\n')) self.assertEqual(response.status_code, 200)