Commit a99017fd authored by Jesus Alvaro C. Pato's avatar Jesus Alvaro C. Pato

created and unit tested functions to render HTML templates

parent 6d1a3ae5
Pipeline #938 failed with stages
<!DOCTYPE html>
<html>
</html>
\ No newline at end of file
from django.urls import resolve
from django.test import TestCase from django.test import TestCase
from .views import HeroesView,HeroCloudView, HeroSunfloweyView, HeroJesterView
# Create your tests here. # Create your tests here.
class HeroesPageTest(TestCase):
def test_heroes_page_returns_correct_html(self):
response = self.client.get('/heroes')
self.assertTemplateUsed(response, 'detail_heroes.html')
class HeroCloudPageTest(TestCase):
def test_cloud_page_returns_correct_html(self):
response = self.client.get('/hero/cloud')
self.assertTemplateUsed(response, 'detail_cloud.html')
class HeroSunfloweyPageTest(TestCase):
def test_sunflowey_page_returns_correct_html(self):
response = self.client.get('/hero/sunflowey')
self.assertTemplateUsed(response, 'detail_sunflowey.html')
class HeroJesterPageTest(TestCase):
def test_jester_page_returns_correct_html(self):
response = self.client.get('/hero/jester')
self.assertTemplateUsed(response, 'detail_jester.html')
from django.conf.urls import url
from .views import HeroesView,HeroCloudView, HeroSunfloweyView, HeroJesterView
urlpatterns = [
url(r'^heroes$', HeroesView.as_view(), name='Heroes'),
url(r'^hero/cloud$', HeroCloudView.as_view(), name='Cloud'),
url(r'^hero/sunflowey$', HeroSunfloweyView.as_view(), name='Sunflowey'),
url(r'^hero/jester$', HeroJesterView.as_view(), name='Jester'),
]
from django.shortcuts import render from django.views.generic.base import TemplateView
# Create your views here. # Create your views here.
class HeroesView(TemplateView):
template_name = 'detail_heroes.html'
class HeroCloudView(TemplateView):
template_name = 'detail_cloud.html'
class HeroSunfloweyView(TemplateView):
template_name = 'detail_sunflowey.html'
class HeroJesterView(TemplateView):
template_name = 'detail_jester.html'
...@@ -37,6 +37,7 @@ INSTALLED_APPS = [ ...@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'heroes',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -13,9 +13,10 @@ Including another URLconf ...@@ -13,9 +13,10 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include 1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
""" """
from django.conf.urls import url from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
urlpatterns = [ urlpatterns = [
url(r'^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