From 6898f8d3bc78f1d6da0b6b77a184f06538938d98 Mon Sep 17 00:00:00 2001 From: Ojus Sharma Date: Tue, 9 Apr 2024 14:30:48 -0700 Subject: [PATCH] Header Element ID's added - IDs added to all elements to aid testing --- .../pages/templates/pages/header.html | 18 +++++------ Django/communicado/pages/tests.py | 30 ++++++++----------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Django/communicado/pages/templates/pages/header.html b/Django/communicado/pages/templates/pages/header.html index 37e01d9f..6238226b 100644 --- a/Django/communicado/pages/templates/pages/header.html +++ b/Django/communicado/pages/templates/pages/header.html @@ -44,26 +44,26 @@ -
- - Logo +
+ + Logo -
diff --git a/Django/communicado/pages/tests.py b/Django/communicado/pages/tests.py index c9d3c8fe..55c89cde 100644 --- a/Django/communicado/pages/tests.py +++ b/Django/communicado/pages/tests.py @@ -6,22 +6,10 @@ from django.test import LiveServerTestCase from django.contrib.auth.hashers import make_password from django.shortcuts import render -#from selenium import webdriver -#from selenium.webdriver.common.keys import Keys -#from selenium.webdriver.chrome.options import Options -import time - -# Example 1 - -#class Hosttest(LiveServerTestCase): - -# def testhomepage(self): -# options = Options() -# options.headless = True -# driver = webdriver.Chrome(options=options) -# driver.get(self.live_server_url) - # try driver.get(self.live_server_url) if driver.get('http://127.0.0.1:8000/') does not work -# assert "Hello, world!" in driver.title +from django.test import TestCase, RequestFactory +from django.contrib.auth.models import User +from django.urls import reverse +from django.contrib.sessions.middleware import SessionMiddleware class UsersTestCase(TestCase): @@ -679,4 +667,12 @@ def test_xyz_page_contains_expected_paragraphs(self): "Join us in this exhilarating adventure as we redefine the way events are experienced and enjoyed. Welcome aboard!" ] for paragraph in expected_paragraphs: - self.assertContains(response, paragraph, html=True) \ No newline at end of file + self.assertContains(response, paragraph, html=True) + + def test_header_not_logged_in(self): + response = self.client.get(reverse('xyz')) + + self.assertEqual(response.status_code, 200) + + self.assertContains(response, "View Cart") + self.assertContains(response, "Login") \ No newline at end of file