Commit f9979f17 authored by King Arthur's avatar King Arthur

Created unit tests for each character page.

parent 271ac4bf
...@@ -2,7 +2,17 @@ from django.test import TestCase ...@@ -2,7 +2,17 @@ from django.test import TestCase
# Create your tests here. # Create your tests here.
class HomePageTest(TestCase): class HomePageTest(TestCase):
def test_home_page_displays_correctly(self): def test_home_page_displays_correctly(self):
response = self.client.get("/") response = self.client.get("/heroes")
self.assertTemplateUsed(response, "home.html") self.assertTemplateUsed(response, "home.html")
class CharacterPageTests(TestCase):
def test_cloud_page_displays_correctly(self):
response = self.client.get("/hero/cloud")
self.assertTemplateUsed(response, "detail_cloud.html")
def test_sunflowey_page_displays_correctly(self):
response = self.client.get("/hero/sunflowey")
self.assertTemplateUsed(response, "detail_sunflowey.html")
def test_jester_page_displays_correctly(self):
response = self.client.get("/hero/jester")
self.assertTemplateUsed(response, "detail_jester.html")
\ No newline at end of file
from django.conf.urls import url from django.conf.urls import url
urlpatterns = [ from .views import HomePageView
from .views import DetailCloudView
from .views import DetailSunfloweyView
from .views import DetailJesterView
urlpatterns = [
url(r"^heroes$", HomePageView.as_view(), name="home"),
url(r"^hero/cloud$", DetailCloudView.as_view(), name="detail_cloud"),
url(r"^hero/sunflowey$", DetailSunfloweyView.as_view(), name="detail_sunflowey"),
url(r"^hero/jester$", DetailJesterView.as_view(), name="detail_jester"),
] ]
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.base import TemplateView
# Create your views here. # Create your views here.
class HomePageView(TemplateView):
template_name = "home.html"
class DetailCloudView(TemplateView):
template_name = "detail_cloud.html"
class DetailSunfloweyView(TemplateView):
template_name = "detail_sunflowey.html"
class DetailJesterView(TemplateView):
template_name = "detail_jester.html"
\ No newline at end of file
...@@ -14,8 +14,9 @@ Including another URLconf ...@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.conf.urls import include, url
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), url(r"^admin/", admin.site.urls),
url(r"", include("heroes.urls")),
] ]
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