Commit 55cd6b41 authored by Kyla Villegas's avatar Kyla Villegas

Resolved seeing a list of heroes with corresponding attributes

parent a8335088
This diff is collapsed.
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>Detail - Cloud</title>
</head>
<body>
<div id ="cloud">
<img src= "{% static 'heroes/images/cloud.png' %}" alt='Cloud' 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>
<button type="button"><a href = http://127.0.0.1:8000/heroes>Back to Heroes List</a></button>
</div>
</body>
</html>
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>Detail - Jester</title>
</head>
<body>
<div id ="jester">
<img src="{% static 'heroes/images/jester.png' %}" alt='Jester' 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>
<button type="button"><a href = http://127.0.0.1:8000/heroes>Back to Heroes List</a></button>
</div>
</body>
</html>
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>Detail - Sunflowey</title>
</head>
<body>
<div id ="sunflowey">
<img src="{% static 'heroes/images/sunflowey.png' %}" alt='Sunflowey' 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>
<button type="button"><a href = http://127.0.0.1:8000/heroes>Back to Heroes List</a></button>
</div>
</body>
</html>
<!-- lists/templates/home.html -->
<html> <html>
<head>
<title>The Will of the Wisps Wiki</title> <title>The Will of the Wisps Wiki</title>
</head>
<body>
<div id ="cloud">
<div id ="sunflowey">
<div id ="jester">
<h1>The Will of the Wisps Wiki</h1>
<a href='/hero/cloud'>Cloud</a>
<p>Health Points: 600</p>
<p>Damage: 57</p>
<a href='/hero/sunflowey'>Sunflowey</a>
<p>Health Points: 650</p>
<p>Damage: 43</p>
<a href='/hero/jester'>Jester</a>
<p>Health Points: 660</p>
<p>Damage: 64</p>
</ul>
</body>
</html> </html>
from django.test import TestCase from django.test import TestCase
class HeroesPageTest(TestCase): class NewHeroTest(TestCase):
def test_uses_heroes_template(self): def test_can_get_heroes_template(self):
response = self.client.get('/') response = self.client.get('/heroes')
self.assertTemplateUsed(response, 'heroes.html') self.assertTemplateUsed(response, 'heroes.html')
class HeroesListPageTest(TestCase): def test_can_get_cloud_template(self):
response = self.client.get('/hero/cloud/')
self.assertTemplateUsed(response, 'detail_cloud.html')
def test_uses_list_template(self): def test_can_get_sunflowey_template(self):
response = self.client.get('/hero') response = self.client.get('/hero/sunflowey/')
self.assertTemplateUsed(response, 'hero_list.html') self.assertTemplateUsed(response, 'detail_sunflowey.html')
def test_can_get_jester_template(self):
response = self.client.get('/hero/jester/')
self.assertTemplateUsed(response, 'detail_jester.html')
from django.urls import path from django.urls import path
from .views import HeroesView, HeroesListView from .views import HeroesTemplateView, CloudTemplateView, SunfloweyTemplateView, JesterTemplateView
urlpatterns = [ urlpatterns = [
path('', HeroesView.as_view(), name='heroes'), path('heroes', HeroesTemplateView.as_view(), name='heroes'),
path('hero', HeroesListView.as_view(), name='heroes-list') path('hero/cloud/', CloudTemplateView.as_view(), name='hero/cloud'),
path('hero/sunflowey/', SunfloweyTemplateView.as_view(), name='hero/sunflowey'),
path('hero/jester/', JesterTemplateView.as_view(), name='hero/jester'),
] ]
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView
# Create your views here. # Create your views here.
class HeroesView(TemplateView): class HeroesTemplateView(TemplateView):
template_name = "heroes.html" template_name = "heroes.html"
class HeroesListView(DetailView): class CloudTemplateView(TemplateView):
model = None template_name = 'detail_cloud.html'
class SunfloweyTemplateView(TemplateView):
template_name = 'detail_sunflowey.html'
class JesterTemplateView(TemplateView):
template_name = 'detail_jester.html'
...@@ -2,7 +2,7 @@ import unittest ...@@ -2,7 +2,7 @@ import unittest
import time import time
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class NewVisitorTest(unittest.TestCase): class NewVisitorTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.browser = webdriver.Firefox() self.browser = webdriver.Firefox()
...@@ -18,29 +18,25 @@ class NewVisitorTest(unittest.TestCase): ...@@ -18,29 +18,25 @@ class NewVisitorTest(unittest.TestCase):
# She notices the page title and header mention # She notices the page title and header mention
# 'The Will of the Wisps Wiki' # 'The Will of the Wisps Wiki'
self.assertIn('The Will of the Wisps Wiki', self.browser.title) self.assertIn('The Will of the Wisps Wiki', self.browser.title)
header_text = self.browser.find_element_by_tag_name('head') # header_text = self.browser.find_elements_by_tag_name('head')
self.assertIn('The Will of the Wisps Wiki', header_text) # self.assertIn('The Will of the Wisps Wiki', header_text)
# 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
cloud_link = self.browser.find_element_by_link_text('Cloud')
cloud_healthpoints = self.browser.find_element_by_tag_name('p') cloud = self.browser.find_element_by_id('cloud')
cloud_damage = self.browser.find_element_by_tag_name('p') sunflowey = self.browser.find_element_by_id('sunflowey')
self.assertIn('Cloud', cloud_link) jester = self.browser.find_element_by_id('jester')
self.assertIn('Cloud', cloud_healthpoints)
self.assertIn('Cloud', cloud_damage) self.assertIn('Cloud', cloud.text)
sunflowey_link = self.browser.find_element_by_link_text('Sunflowey') self.assertIn('Sunflowey', sunflowey.text)
sunflowey_healthpoints = self.browser.find_element_by_tag_name('p') self.assertIn('Jester', jester.text)
sunflowey_damage = self.browser.find_element_by_tag_name('p') self.assertIn('Health Points:', cloud.text)
self.assertIn('Sunflowey', sunflowey_link) self.assertIn('Damage:', cloud.text)
self.assertIn('Sunflowey', sunflowey_healthpoints) self.assertIn('Health Points:', sunflowey.text)
self.assertIn('Sunflowey', sunflowey_damage) self.assertIn('Damage:', sunflowey.text)
jester_link = self.browser.find_element_by_link_text('Jester') self.assertIn('Health Points:', jester.text)
jester_healthpoints = self.browser.find_element_by_tag_name('p') self.assertIn('Damage:', jester.text)
jester_damage = self.browser.find_element_by_tag_name('p')
self.assertIn('Jester', jester_link)
self.assertIn('Jester', jester_healthpoints)
self.assertIn('Jester', jester_damage)
# 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).
......
...@@ -123,3 +123,7 @@ USE_TZ = True ...@@ -123,3 +123,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.0/howto/static-files/ # https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'heroes/static'),
]
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