Commit ba13a9c1 authored by Ayn Collado's avatar Ayn Collado

I finished it

parent 729c5ab3
...@@ -6496,3 +6496,5 @@ myenv/Scripts/winsound.pyd ...@@ -6496,3 +6496,5 @@ myenv/Scripts/winsound.pyd
myenv/Scripts/__pycache__/django-admin.cpython-38.pyc myenv/Scripts/__pycache__/django-admin.cpython-38.pyc
.vscode/launch.json .vscode/launch.json
.vscode/launch.json .vscode/launch.json
heroes/geckodriver.log
heroes/__pycache__/tests.cpython-38.pyc
from selenium import webdriver from selenium import webdriver
from django.urls import resolve from django.urls import resolve
from .views import home_page
import unittest import unittest
class NewVisitorTest(unittest.TestCase): class NewVisitorTest(unittest.TestCase):
...@@ -12,14 +13,13 @@ class NewVisitorTest(unittest.TestCase): ...@@ -12,14 +13,13 @@ 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
self.browser.get('http://localhost:8000') self.browser.get('http://localhost:8000/heroes')
# 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) self.assertIn('The Will of the Wisps Wiki', self.browser.title)
# 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
def test_cloud_in_home_page(self):
self.browser.get('http://localhost:8000')
detail = self.browser.find_element_by_id('cloud_name') detail = self.browser.find_element_by_id('cloud_name')
self.assertEqual(detail.get_attribute('innerHTML'), 'Cloud') self.assertEqual(detail.get_attribute('innerHTML'), 'Cloud')
detail = self.browser.find_element_by_id('cloud_hp') detail = self.browser.find_element_by_id('cloud_hp')
...@@ -27,6 +27,8 @@ class NewVisitorTest(unittest.TestCase): ...@@ -27,6 +27,8 @@ class NewVisitorTest(unittest.TestCase):
detail = self.browser.find_element_by_id('cloud_ad') detail = self.browser.find_element_by_id('cloud_ad')
self.assertEqual(detail.get_attribute('innerHTML'), '57') self.assertEqual(detail.get_attribute('innerHTML'), '57')
def test_sunflowey_in_home_page(self):
self.browser.get('http://localhost:8000')
detail = self.browser.find_element_by_id('sunflowey_name') detail = self.browser.find_element_by_id('sunflowey_name')
self.assertEqual(detail.get_attribute('innerHTML'), 'Sunflowey') self.assertEqual(detail.get_attribute('innerHTML'), 'Sunflowey')
detail = self.browser.find_element_by_id('sunflowey_hp') detail = self.browser.find_element_by_id('sunflowey_hp')
...@@ -34,6 +36,8 @@ class NewVisitorTest(unittest.TestCase): ...@@ -34,6 +36,8 @@ class NewVisitorTest(unittest.TestCase):
detail = self.browser.find_element_by_id('sunflowey_ad') detail = self.browser.find_element_by_id('sunflowey_ad')
self.assertEqual(detail.get_attribute('innerHTML'), '43') self.assertEqual(detail.get_attribute('innerHTML'), '43')
def test_jester_in_home_page(self):
self.browser.get('http://localhost:8000')
detail = self.browser.find_element_by_id('jester_name') detail = self.browser.find_element_by_id('jester_name')
self.assertEqual(detail.get_attribute('innerHTML'), 'Jester') self.assertEqual(detail.get_attribute('innerHTML'), 'Jester')
detail = self.browser.find_element_by_id('jester_hp') detail = self.browser.find_element_by_id('jester_hp')
...@@ -42,23 +46,30 @@ class NewVisitorTest(unittest.TestCase): ...@@ -42,23 +46,30 @@ class NewVisitorTest(unittest.TestCase):
self.assertEqual(detail.get_attribute('innerHTML'), '64') self.assertEqual(detail.get_attribute('innerHTML'), '64')
# When she selects one of the heroes, she is sent to another page def test_cloud_check_title_and_heading(self):
# containing more information about the hero (additional stats, lore, image).
self.browser.get('http://localhost:8000/hero/cloud') self.browser.get('http://localhost:8000/hero/cloud')
self.browser.get('http://localhost:8000/hero/sunflowey') self.assertIn('Detail - Cloud', self.browser.title)
self.browser.get('http://localhost:8000/hero/jester')
# She spots the page title and header mentions the name of the hero she selected.
detail = self.browser.find_element_by_id('cloud_title')
self.assertEqual(detail.get_attribute('innerHTML'), 'Detail - Cloud')
detail = self.browser.find_element_by_id('cloud_heading') detail = self.browser.find_element_by_id('cloud_heading')
self.assertEqual(detail.get_attribute('innerHTML'), 'Detail - Cloud') self.assertEqual(detail.get_attribute('innerHTML'), 'Detail - Cloud')
# While she is in a specific hero's page, she sees a button labeled "Back to Heroes List". def test_sunflowey_check_title_and_heading(self):
# She clicks this and she is redirected back to the wiki's homepage. self.browser.get('http://localhost:8000/hero/sunflowey')
button = self.browser.find_element_by_id('back_button') self.assertIn('Detail - Sunflowey', self.browser.title)
self.assertEqual(button.get_attribute('innerHTML'), 'Back to Heroes List') detail = self.browser.find_element_by_id('sunflowey_heading')
self.assertEqual(detail.get_attribute('innerHTML'), 'Detail - Sunflowey')
def test_jester_check_title_and_heading(self):
self.browser.get('http://localhost:8000/hero/jester')
self.assertIn('Detail - Jester', self.browser.title)
detail = self.browser.find_element_by_id('jester_heading')
self.assertEqual(detail.get_attribute('innerHTML'), 'Detail - Jester')
def check_button(self):
homeButton = self.browser.find_element_by_id('homeButton').click()
self.assertEqual(resolve('/').func, home_page)
def test_pass(self):
self.fail('Finish the test!') self.fail('Finish the test!')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(warnings='ignore') unittest.main(warnings='ignore')
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title id='cloud_title'>Detail - Cloud</title> <title>Detail - Cloud</title>
</head> </head>
<body> <body>
<img src="https://opengameart.org/sites/default/files/styles/medium/public/bigvioletcloud_0.png" style="width: 10vw;" /> <img src="https://opengameart.org/sites/default/files/styles/medium/public/bigvioletcloud_0.png" style="width: 10vw;" />
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title id='jester_title'>Detail - Jester</title> <title>Detail - Jester</title>
</head> </head>
<body> <body>
<img src="https://opengameart.org/sites/default/files/styles/medium/public/jester.png" style="width: 10vw;"/> <img src="https://opengameart.org/sites/default/files/styles/medium/public/jester.png" style="width: 10vw;"/>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title id='sunflowey_title'>Detail - Sunflowey</title> <title>Detail - Sunflowey</title>
</head> </head>
<body> <body>
<img src="https://opengameart.org/sites/default/files/styles/medium/public/sunflower_plant_enemy_game_character_sprites.jpg" style="width: 10vw;" /> <img src="https://opengameart.org/sites/default/files/styles/medium/public/sunflower_plant_enemy_game_character_sprites.jpg" style="width: 10vw;" />
......
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