Commit 274dc571 authored by KY-2187's avatar KY-2187

edited lab1_functional_test.py

parent 88b9bc9c
...@@ -12,18 +12,18 @@ class cloudTest(TestCase): ...@@ -12,18 +12,18 @@ class cloudTest(TestCase):
def test_cloud_returns_correct_html(self): def test_cloud_returns_correct_html(self):
response = self.client.get('/hero/cloud') response = self.client.get('/hero/cloud')
self.assertTemplateUsed(response, 'cloud.html') self.assertTemplateUsed(response, 'detail_cloud.html')
class sunfloweyTest(TestCase): class sunfloweyTest(TestCase):
def test_sunflowey_returns_correct_html(self): def test_sunflowey_returns_correct_html(self):
response = self.client.get('/hero/sunflowey') response = self.client.get('/hero/sunflowey')
self.assertTemplateUsed(response, 'sunflowey.html') self.assertTemplateUsed(response, 'detail_sunflowey.html')
class jesterTest(TestCase): class jesterTest(TestCase):
def test_jester_returns_correct_html(self): def test_jester_returns_correct_html(self):
response = self.client.get('/hero/sunflowey') response = self.client.get('/hero/jester')
self.assertTemplateUsed(response, 'jester.html') self.assertTemplateUsed(response, 'detail_jester.html')
from django.conf.urls import url
from .views import HeroesView, CloudView, SunfloweyView, JesterView
urlpatterns = [
url(r'^heroes$', HeroesView.as_view(), name='heroes_show'),
url(r'^hero/cloud$', CloudView.as_view(), name='cloud_show'),
url(r'^hero/sunflowey$', SunfloweyView.as_view(), name='sunflowey_show'),
url(r'^hero/jester$', JesterView.as_view(), name='jester_show'),
]
\ No newline at end of file
...@@ -11,7 +11,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -11,7 +11,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'
...@@ -19,13 +19,31 @@ class NewVisitorTest(unittest.TestCase): ...@@ -19,13 +19,31 @@ 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(self.browser.current_url, 'https://localhost:8000/heroes')
# 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.get('https://localhost:8000/hero/cloud')
self.assertIn('Health Points', self.browser.find_element_by_id('hero_health').text)
self.assertIn('Base Attack Damage', self.browser.find_element_by_id('hero_attack').text)
self.assertIn('Skills', self.browser.find_element_by_id('hero_skills').text)
self.assertIn('Lore', self.browser.find_element_by_id('hero_lore').text)
self.assertIn('.png', self.browser.find_element_by_id('hero_image').get_attribute('src'))
# 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('Detail -', 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.
self.fail('Finish the test!') self.fail('Finish the test!')
\ No newline at end of file
if __name__ == '__main__':
unittest.main(warnings = 'ignore')
from django.conf.urls import urls
from .views import HeroesView, CloudView, SunfloweyView, JesterView
urlpatterns = [
url(r'^heroes/$', heroesView.as_view(), name='heroes_show'),
url(r'^hero/cloud$', cloudView.as_view(), name='cloud_show'),
url(r'^hero/sunflowey$', sunfloweyView.as_view(), name='sunflowey_show'),
url(r'^hero/jester$', jesterView.as_view(), name='jester_show')
]
\ No newline at end of file
...@@ -37,7 +37,7 @@ INSTALLED_APPS = [ ...@@ -37,7 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'heroes' 'heroes',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
from django.conf.urls import include, urls from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
......
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