Commit 3e74c1f4 authored by Alec Wang's avatar Alec Wang

completed functional tests

parent bfb8004c
This diff is collapsed.
{% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
...@@ -6,7 +7,7 @@ ...@@ -6,7 +7,7 @@
</head> </head>
<body> <body>
<img src="./jester.png" style="width: 10vw;" /> <img src="{% static "./jester.png" %}" style="width: 10vw;" />
<h1>Detail - Jester</h1> <h1>Detail - Jester</h1>
<dl> <dl>
<dt>Health Points</dt> <dt>Health Points</dt>
......
{% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
...@@ -6,7 +7,7 @@ ...@@ -6,7 +7,7 @@
</head> </head>
<body> <body>
<img src="./sunflowey.png" style="width: 10vw;" /> <img src="{% static "./sunflowey.png" %}" style="width: 10vw;" />
<h1>Detail - Sunflowey</h1> <h1>Detail - Sunflowey</h1>
<dl> <dl>
<dt>Health Points</dt> <dt>Health Points</dt>
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Will of the Wisps</title> <title>The Will of the Wisps Wiki</title>
</head> </head>
<body> <body>
<li><a href="{% url 'hero_cloud' %}">Cloud(HP:600,Damage:57)</a></li> <li><a href="{% url 'hero_cloud' %}">Cloud(HP:600,Damage:57)</a>
<li><a href="{% url 'hero_sunflowey' %}">Sunflowey(HP:650,Damage:43)</a></li> <a href="{% url 'hero_sunflowey' %}">Sunflowey(HP:650,Damage:43)</a>
<li><a href="{% url 'hero_jester' %}">Jester(HP:660,Damage:64)</a></li> <a href="{% url 'hero_jester' %}">Jester(HP:660,Damage:64)</a></li>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -4,6 +4,7 @@ from django.conf.urls import include, url ...@@ -4,6 +4,7 @@ from django.conf.urls import include, url
from .views import * from .views import *
urlpatterns = [ urlpatterns = [
url(r'^$', heroes, name="home_page"),
url(r'^heroes/$', heroes, name="heroes"), url(r'^heroes/$', heroes, name="heroes"),
url(r'^hero/cloud$', hero_cloud, name="hero_cloud"), url(r'^hero/cloud$', hero_cloud, name="hero_cloud"),
url(r'^hero/sunflowey$', hero_sunflowey, name="hero_sunflowey"), url(r'^hero/sunflowey$', hero_sunflowey, name="hero_sunflowey"),
......
...@@ -3,6 +3,10 @@ from django.shortcuts import render ...@@ -3,6 +3,10 @@ from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
def home_page(request):
return HttpResponse('<html><title>The Will of the Wisps Wiki</title></html>')
def heroes(request): def heroes(request):
return render(request, 'heroes.html') return render(request, 'heroes.html')
......
...@@ -12,7 +12,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -12,7 +12,7 @@ class NewVisitorTest(unittest.TestCase):
def test_can_display_a_heroes_list_and_more_information_per_hero(self): def test_can_display_a_heroes_list_and_more_information_per_hero(self):
# Widget has heard about a new wiki app for the game called The Will of the Wisps. # Widget has heard about a new wiki app for the game called The Will of the Wisps.
# She goes to check out its homepage # She goes to check out its homepage
browser.get('http://localhost:8000') self.browser.get('http://localhost:8000/')
# 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'
...@@ -20,13 +20,23 @@ class NewVisitorTest(unittest.TestCase): ...@@ -20,13 +20,23 @@ 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.assertIn('Cloud(HP:600,Damage:57)', self.browser.page_source)
self.assertIn('Sunflowey(HP:650,Damage:43)', self.browser.page_source)
self.assertIn('Jester(HP:660,Damage:64)', self.browser.page_source)
# 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).
self.browser.find_element_by_link_text(
"Cloud(HP:600,Damage:57)").click()
# 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.page_source)
# 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.
self.browser.find_element_by_css_selector("input[type=submit]").click()
self.assertIn('The Will of the Wisps Wiki', self.browser.title)
self.fail('Finish the test!') self.fail('Finish the test!')
if __name__ == '__main__':
unittest.main(warnings='ignore')
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