Redid functional test.

parent 0667c726
from selenium import webdriver
import unittest
from selenium import webdriver
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def setUp(self):
self.browser = webdriver.Firefox()
def tearDown(self):
self.browser.quit()
def tearDown(self):
self.browser.quit()
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.
# She goes to check out its homepage
self.browser.get('http://localhost:8000/heroes')
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.
# She goes to check out its homepage
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)
# 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)
# She sees a list containing three heroes with their corresponding
# names, health points, and damage
# She sees a list containing three heroes with their corresponding
# names, health points, and damage
self.assertIn('http://localhost:8000/heroes', self.browser.current_url)
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
self.browser.get('http://localhost:8000/hero/cloud')
# When she selects one of the heroes, she is sent to another page
# containing more information about the hero (additional stats, lore, image).
self.browser.get('http://localhost:8000/hero/cloud')
# She spots the page title and header mentions the name of the hero she selected.
self.assertIn('Detail - Cloud', self.browser.title)
# She spots the page title and header mentions the name of the hero she selected.
self.assertIn('Detail - Cloud', self.browser.title)
# 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.
self.browser.get('http://localhost:8000/heroes')
# 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.
self.browser.get('http://localhost:8000/heroes')
# She decides to do it again UwU
self.browser.get('http://localhost:8000/hero/sunflowey')
self.assertIn('Detail - Sunflowey', self.browser.title)
self.browser.get('http://localhost:8000/heroes')
# She decides to do it again
self.browser.get('http://localhost:8000/hero/sunflowey')
self.assertIn('Detail - Sunflowey', self.browser.title)
self.browser.get('http://localhost:8000/heroes')
self.browser.get('http://localhost:8000/hero/jester')
self.assertIn('Detail - Jester', self.browser.title)
self.browser.get('http://localhost:8000/heroes')
self.browser.get('http://localhost:8000/hero/jester')
self.assertIn('Detail - Jester', self.browser.title)
self.browser.get('http://localhost:8000/heroes')
self.fail('Finish the test!')
if __name__ == '__main__':
unittest.main(warnings='ignore')
unittest.main(warnings='ignore')
from django.urls import resolve
from django.test import TestCase
class HomePageTest(TestCase):
def test_heroes_page_returns_correct_html(self):
response = self.client.get('/heroes/')
self.assertTemplateUsed(response, 'heroes.html')
def test_heroes_page_returns_correct_html(self):
response = self.client.get('/heroes/')
self.assertTemplateUsed(response, 'heroes.html')
def test_cloud_page_returns_correct_html(self):
response = self.client.get('/hero/cloud')
self.assertTemplateUsed(response, 'detail_cloud.html')
def test_cloud_page_returns_correct_html(self):
response = self.client.get('/hero/cloud')
self.assertTemplateUsed(response, 'detail_cloud.html')
def test_sunflowey_page_returns_correct_html(self):
response = self.client.get('/hero/sunflowey')
self.assertTemplateUsed(response, 'detail_sunflowey.html')
def test_sunflowey_page_returns_correct_html(self):
response = self.client.get('/hero/sunflowey')
self.assertTemplateUsed(response, 'detail_sunflowey.html')
def test_jester_page_returns_correct_html(self):
response = self.client.get('/hero/jester')
self.assertTemplateUsed(response, 'detail_jester.html')
def test_jester_page_returns_correct_html(self):
response = self.client.get('/hero/jester')
self.assertTemplateUsed(response, 'detail_jester.html')
from django.shortcuts import render
def heroes_page(request):
return render(request, 'heroes.html')
return render(request, 'heroes.html')
def cloud_page(request):
return render(request, 'detail_cloud.html')
return render(request, 'detail_cloud.html')
def sunflowey_page(request):
return render(request, 'detail_sunflowey.html')
return render(request, 'detail_sunflowey.html')
def jester_page(request):
return render(request, 'detail_jester.html')
return render(request, 'detail_jester.html')
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