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>
<head>
<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>
from django.test import TestCase
class HeroesPageTest(TestCase):
class NewHeroTest(TestCase):
def test_uses_heroes_template(self):
response = self.client.get('/')
def test_can_get_heroes_template(self):
response = self.client.get('/heroes')
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):
response = self.client.get('/hero')
self.assertTemplateUsed(response, 'hero_list.html')
def test_can_get_sunflowey_template(self):
response = self.client.get('/hero/sunflowey/')
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 .views import HeroesView, HeroesListView
from .views import HeroesTemplateView, CloudTemplateView, SunfloweyTemplateView, JesterTemplateView
urlpatterns = [
path('', HeroesView.as_view(), name='heroes'),
path('hero', HeroesListView.as_view(), name='heroes-list')
path('heroes', HeroesTemplateView.as_view(), name='heroes'),
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.detail import DetailView
# Create your views here.
class HeroesView(TemplateView):
class HeroesTemplateView(TemplateView):
template_name = "heroes.html"
class HeroesListView(DetailView):
model = None
class CloudTemplateView(TemplateView):
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
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
......@@ -18,29 +18,25 @@ class NewVisitorTest(unittest.TestCase):
# She notices the page title and header mention
# 'The Will of the Wisps Wiki'
self.assertIn('The Will of the Wisps Wiki', self.browser.title)
header_text = self.browser.find_element_by_tag_name('head')
self.assertIn('The Will of the Wisps Wiki', header_text)
# header_text = self.browser.find_elements_by_tag_name('head')
# self.assertIn('The Will of the Wisps Wiki', header_text)
# She sees a list containing three heroes with their corresponding
# 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_damage = self.browser.find_element_by_tag_name('p')
self.assertIn('Cloud', cloud_link)
self.assertIn('Cloud', cloud_healthpoints)
self.assertIn('Cloud', cloud_damage)
sunflowey_link = self.browser.find_element_by_link_text('Sunflowey')
sunflowey_healthpoints = self.browser.find_element_by_tag_name('p')
sunflowey_damage = self.browser.find_element_by_tag_name('p')
self.assertIn('Sunflowey', sunflowey_link)
self.assertIn('Sunflowey', sunflowey_healthpoints)
self.assertIn('Sunflowey', sunflowey_damage)
jester_link = self.browser.find_element_by_link_text('Jester')
jester_healthpoints = self.browser.find_element_by_tag_name('p')
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)
cloud = self.browser.find_element_by_id('cloud')
sunflowey = self.browser.find_element_by_id('sunflowey')
jester = self.browser.find_element_by_id('jester')
self.assertIn('Cloud', cloud.text)
self.assertIn('Sunflowey', sunflowey.text)
self.assertIn('Jester', jester.text)
self.assertIn('Health Points:', cloud.text)
self.assertIn('Damage:', cloud.text)
self.assertIn('Health Points:', sunflowey.text)
self.assertIn('Damage:', sunflowey.text)
self.assertIn('Health Points:', jester.text)
self.assertIn('Damage:', jester.text)
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
......
......@@ -123,3 +123,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.0/howto/static-files/
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