Commit ab6ba34f authored by Patrick James Ong's avatar Patrick James Ong

Followed slidesets for tests, urls, and views

parent debd1400
Pipeline #821 canceled with stages
from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest
# Create your tests here.
class HomePageTest(TestCase):
def test_uses_home_template(self):
response = self.client.get('/')
self.assertTemplateUsed(response, 'home.html')
class CloudPageTest(TestCase):
def test_uses_hero_template(self):
response = self.client.get('/cloud/')
self.assertTemplateUsed(response, 'detail_cloud.html')
class JesterPageTest(TestCase):
def test_uses_hero_template(self):
response = self.client.get('/jester/')
self.assertTemplateUsed(response, 'detailed_jester.html')
class SunfloweyPageTest(TestCase):
def test_uses_hero_template(self):
response = self.client.get('/sunflowey/')
self.assertTemplateUsed(response, 'detailed_sunflowey.html')
from django.conf.urls import url
from .views import HomeListView, CloudDetailView, JesterDetailView, SunfloweyDetailView
urlpatterns = [
url(r'^$', HomeListView.as_view(), name='home'),
url(r'^cloud/$', CloudDetailView.as_view(), name='detail_cloud'),
url(r'^jester/$', JesterDetailView.as_view(), name='detail_jester'),
url(r'^sunflowey/$', SunfloweyDetailView.as_view(), name='detail_sunflowey'),
]
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.base import TemplateView
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
# Create your views here.
class HomeListView(ListView):
template_name = 'home.html'
class CloudDetailView(DetailView):
template_name = 'detail_cloud.html'
class JesterDetailView(DetailView):
template_name = 'detail_jester.html'
class SunfloweyDetailView(DetailView):
template_name = 'detail_sunflowey.html'
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