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.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):
found = resolve('/')
self.assertEqual(found.func, home_page)
class HeroesListPageTest(TestCase):
def test_home_page_returns_correct_html(self):
request = HttpRequest()
response = home_page(request)
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>'))
def test_uses_list_template(self):
response = self.client.get('/hero')
self.assertTemplateUsed(response, 'hero_list.html')
from django.urls import path
from .views import home_page
from .views import HeroesView, HeroesListView
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.http import HttpResponse
from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView
# Create your views here.
def home_page(request):
return HttpResponse('<html><title>The Will of the Wisps Wiki</title></html>')
class HeroesView(TemplateView):
template_name = "heroes.html"
class HeroesListView(DetailView):
model = None
......@@ -13,7 +13,7 @@ class NewVisitorTest(unittest.TestCase):
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')
self.browser.get('http://localhost:8000/heroes')
# She notices the page title and header mention
# 'The Will of the Wisps Wiki'
......@@ -72,7 +72,7 @@ class NewVisitorTest(unittest.TestCase):
self.assertIn('Back to Heroes List', button)
button.click()
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(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