Commit 37b82c42 authored by Dan Mark Restoles's avatar Dan Mark Restoles

updated lab functional tests

parent c4ba495a
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.list import ListView from django.views.generic import TemplateView
from django.views.generic.detail import DetailView
class HeroesView(ListView): class HeroesView(TemplateView):
pass template_name = 'list_heroes.html'
class HeroView(DetailView): class HeroView(TemplateView):
template_name = "detail" template_name = "detail"
\ No newline at end of file
...@@ -21,31 +21,21 @@ class NewVisitorTest(unittest.TestCase): ...@@ -21,31 +21,21 @@ 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
heroesURL = self.browser.get('http://localhost:8000/heroes') response = self.browser.get('http://localhost:8000/heroes')
self.assertIn('<dl>', heroesURL) self.assertEqual(response.resolver_match.func.__name__, HeroesView.as_view().__name__)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('</dl>', heroesURL)
self.assertIn('<dl>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('</dl>', heroesURL)
self.assertIn('<dl>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('<dt></dt><dd></dd>', heroesURL)
self.assertIn('</dl>', heroesURL)
# 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).
response = self.browser.get('http://localhost:8000/heroes/cloud')
self.assertEqual(response.resolver_match.func.__name__, HeroView.as_view().__name__)
# 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.assertEqual(self.browser.title, 'Detail - Cloud')
# 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.
response = self.browser.get('http://localhost:8000/heroes')
self.assertEqual(response.resolver_match.func.__name__, HeroesView.as_view().__name__)
self.fail('Finish the test!') self.fail('Finish the test!')
......
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