Created home.html and added it to templates, worked on unit testing

parent ab503b02
from django.test import TestCase from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest
class HomePageTest(TestCase): class HomePageTest(TestCase):
...@@ -10,20 +12,20 @@ class HomePageTest(TestCase): ...@@ -10,20 +12,20 @@ class HomePageTest(TestCase):
class CloudTest(TestCase): class CloudTest(TestCase):
def test_uses_cloud_template(self): def test_uses_cloud_template(self):
response = self.client.get('/heroes/cloud/') response = self.client.get('/hero/cloud/')
self.assertTemplateUsed(response, 'detail_cloud.html') self.assertTemplateUsed(response, 'detail_cloud.html')
class JesterTest(TestCase): class JesterTest(TestCase):
def test_uses_jester_template(self): def test_uses_jester_template(self):
response = self.client.get('/heroes/jester/') response = self.client.get('/hero/jester/')
self.assertTemplateUsed(response, 'detail_jester.html') self.assertTemplateUsed(response, 'detail_jester.html')
class SunfloweyTest(TestCase): class SunfloweyTest(TestCase):
def test_uses_sunflowey_template(self): def test_uses_sunflowey_template(self):
response = self.client.get('/heroes/sunflowey/') response = self.client.get('/hero/sunflowey/')
self.assertTemplateUsed(response, 'detail_sunflowey.html') self.assertTemplateUsed(response, 'detail_sunflowey.html')
...@@ -4,8 +4,8 @@ from .views import HomeListView, CloudDetailView, JesterDetailView, SunfloweyDet ...@@ -4,8 +4,8 @@ from .views import HomeListView, CloudDetailView, JesterDetailView, SunfloweyDet
urlpatterns = [ urlpatterns = [
url(r'^$', HomeListView.as_view(), name='home'), url(r'^$', HomeListView.as_view(), name='home'),
url(r'^heroes/cloud/$', CloudDetailView.as_view(), name='detail_cloud'), url(r'^hero/cloud/$', CloudDetailView.as_view(), name='detail_cloud'),
url(r'^heroes/jester/$', JesterDetailView.as_view(), name='detail_jester'), url(r'^hero/jester/$', JesterDetailView.as_view(), name='detail_jester'),
url(r'^heroes/sunflowey/$', SunfloweyDetailView.as_view(), name='detail_sunflowey'), url(r'^hero/sunflowey/$', SunfloweyDetailView.as_view(), name='detail_sunflowey'),
] ]
...@@ -2,20 +2,19 @@ from django.shortcuts import render ...@@ -2,20 +2,19 @@ from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
# Create your views here. # Create your views here.
class HomeListView(TemplateView): class HomeListView(TemplateView):
template_name = "home.html" template_name = 'home.html'
class CloudDetailView(DetailView): class CloudDetailView(TemplateView):
template_name = "detail_cloud.html" template_name = 'detail_cloud.html'
class JesterDetailView(DetailView): class JesterDetailView(TemplateView):
template_name = "detail_jester.html" template_name = 'detail_jester.html'
class SunfloweyDetailView(DetailView): class SunfloweyDetailView(TemplateView):
template_name = "detail_sunflowey.html" template_name = 'detail_sunflowey.html'
\ No newline at end of file \ No newline at end of file
...@@ -20,29 +20,29 @@ class NewVisitorTest(unittest.TestCase): ...@@ -20,29 +20,29 @@ class NewVisitorTest(unittest.TestCase):
# She sees a list containing three heroes with their corresponding # She sees a list containing three heroes with their corresponding
# names, health points, and damage # names, health points, and damage
self.assertIn('Cloud', self.browser.body) self.assertIn('Cloud', self.browser.find_element_by_id('Cloud').text)
self.assertIn('Health Points: 600', self.browser.body) self.assertIn('Health Points: 600', self.browser.find_element_by_id('HP1').text)
self.assertIn('Base Attack Damage: 57', self.browser.body) self.assertIn('Base Attack Damage: 57', self.browser.find_element_by_id('BAD1').text)
self.assertIn('Jester', self.browser.body) self.assertIn('Jester', self.browser.find_element_by_id('Jester').text)
self.assertIn('Health Points: 660', self.browser.body) self.assertIn('Health Points: 660', self.browser.find_element_by_id('HP2').text)
self.assertIn('Base Attack Damage: 64', self.browser.body) self.assertIn('Base Attack Damage: 64', self.browser.find_element_by_id('BAD2').text)
self.assertIn('Sunflowey', self.browser.body) self.assertIn('Sunflowey', self.browser.find_element_by_id('Sunflowey').text)
self.assertIn('Health Points: 650', self.browser.body) self.assertIn('Health Points: 650', self.browser.find_element_by_id('HP3').text)
self.assertIn('Base Attack Damage: 43', self.browser.body) self.assertIn('Base Attack Damage: 43', self.browser.find_element_by_id('BAD3').text)
# When she selects one of the heroes, she is sent to another page # When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image). # containing more information about the hero (additional stats, lore, image).
browser.get('http://localhost:8000/hero/cloud') self.browser.get('http://localhost:8000/hero/cloud/')
browser.get('http://localhost:8000/hero/sunflowey') self.browser.get('http://localhost:8000/hero/jester/')
browser.get('http://localhost:8000/hero/jester') self.browser.get('http://localhost:8000/hero/sunflowey/')
# She spots the page title and header mentions the name of the hero she selected. # She spots the page title and header mentions the name of the hero she selected.
self.assertIn('Cloud', self.browser.title) self.assertIn('Cloud', self.browser.title)
self.assertIn('Sunflowey', self.browser.title)
self.assertIn('Jester', self.browser.title) self.assertIn('Jester', self.browser.title)
self.assertIn('Sunflowey', self.browser.title)
# While she is in a specific hero's page, she sees a button labeled "Back to Heroes List". # While she is in a specific hero's page, she sees a button labeled "Back to Heroes List".
# She clicks this and she is redirected back to the wiki's homepage. # She clicks this and she is redirected back to the wiki's homepage.
......
<!DOCTYPE html>
<html>
<head>
<title>Detail - Cloud</title>
</head>
<body>
<img src="./cloud.png" style="width: 10vw;" />
<h1>Detail - Cloud</h1>
<dl>
<dt>Health Points</dt><dd>600</dd>
<dt>Base Attack Damage</dt><dd>57</dd>
<dt>Skills</dt><dd>Nimbus, Rain Cloud, Thunderbolt</dd>
<dt>Lore</dt><dd>I am a cloud. When I pee you call it 'rain'.</dd>
</dl>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Detail - Jester</title>
</head>
<body>
<img src="./jester.png" style="width: 10vw;"/>
<h1>Detail - Jester</h1>
<dl>
<dt>Health Points</dt><dd>660</dd>
<dt>Base Attack Damage</dt><dd>64</dd>
<dt>Skills</dt><dd>Laugh, Dance, Smile</dd>
<dt>Lore</dt><dd>I do it for the LOLs.</dd>
</dl>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Detail - Sunflowey</title>
</head>
<body>
<img src="./sunflowey.png" style="width: 10vw;" />
<h1>Detail - Sunflowey</h1>
<dl>
<dt>Health Points</dt><dd>650</dd>
<dt>Base Attack Damage</dt><dd>43</dd>
<dt>Skills</dt><dd>Power Pellet, Sunshine, Pollen Punch</dd>
<dt>Lore</dt><dd>I am Sunflowey. Sometimes a sun, sometimes a flower.</dd>
</dl>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title>The Will of the Wisps Wiki</title>
<h1 id="WillOfWisps">The Will of the Wisps Wiki</h1>
</head>
<body>
<ol id="Cloud"> Cloud
<ul>
<li id="HP1">Health Points: 600</li>
<li id="BAD1">Base Attack Damage: 57</li>
</ul>
</ol>
<ol id="Jester"> Jester
<ul>
<li id="HP2">Health Points: 660</li>
<li id="BAD2">Base Attack Damage: 64</li>
</ul>
</ol>
<ol id="Sunflowey"> Sunflowey
<ul>
<li id="HP3">Health Points: 650</li>
<li id="BAD3">Base Attack Damage: 43</li>
</ul>
</ol>
</body>
</html>
...@@ -55,7 +55,7 @@ ROOT_URLCONF = 'willowisp.urls' ...@@ -55,7 +55,7 @@ ROOT_URLCONF = 'willowisp.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'heroes', 'templates')],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment