Commit a8335088 authored by Kyla Villegas's avatar Kyla Villegas

Refactored files reached an error on the QuerySet

parent fd38ee0e
<html>
<title>The Will of the Wisps Wiki</title>
</html>
from django.urls import resolve
from django.test import TestCase from django.test import TestCase
from django.http import HttpRequest
from .views import home_page class HeroesPageTest(TestCase):
class HomePageTest(TestCase): def test_uses_heroes_template(self):
response = self.client.get('/')
self.assertTemplateUsed(response, 'heroes.html')
def test_root_url_resolves_to_home_page_view(self): class HeroesListPageTest(TestCase):
found = resolve('/')
self.assertEqual(found.func, home_page)
def test_home_page_returns_correct_html(self): def test_uses_list_template(self):
request = HttpRequest() response = self.client.get('/hero')
response = home_page(request) self.assertTemplateUsed(response, 'hero_list.html')
html = response.content.decode('utf8')
self.assertTrue(html.startswith('<html>'))
self.assertIn('<title>The Will of the Wisps Wiki</title>', html)
self.assertTrue(html.endswith('</html>'))
from django.urls import path from django.urls import path
from .views import home_page from .views import HeroesView, HeroesListView
urlpatterns = [ urlpatterns = [
path('', home_page, name='home_page'), path('', HeroesView.as_view(), name='heroes'),
path('hero', HeroesListView.as_view(), name='heroes-list')
] ]
from django.shortcuts import render from django.views.generic.base import TemplateView
from django.http import HttpResponse from django.views.generic.detail import DetailView
# Create your views here. # Create your views here.
def home_page(request): class HeroesView(TemplateView):
return HttpResponse('<html><title>The Will of the Wisps Wiki</title></html>') template_name = "heroes.html"
class HeroesListView(DetailView):
model = None
...@@ -13,7 +13,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -13,7 +13,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
self.browser.get('http://localhost:8000') self.browser.get('http://localhost:8000/heroes')
# 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'
...@@ -72,7 +72,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -72,7 +72,7 @@ class NewVisitorTest(unittest.TestCase):
self.assertIn('Back to Heroes List', button) self.assertIn('Back to Heroes List', button)
button.click() button.click()
time.sleep(1) time.sleep(1)
self.assertIn(browser.getCurrentUrl(), 'http://localhost:8000') self.assertIn(browser.getCurrentUrl(), 'http://localhost:8000/heroes')
# input.send_keys('Back to Heroes List') # input.send_keys('Back to Heroes List')
# input.send_keys(Keys.Enter) # input.send_keys(Keys.Enter)
......
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