Commit 8035d270 authored by Alysha Columbres's avatar Alysha Columbres

Created and tested the other three views for the ingredients model

parent 2e3eef31
<!DOCTYPE html>
<html>
<head>
<title>Ingredients - Create</title>
</head>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Ingredients - Detail</title>
</head>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Ingredients - Update</title>
</head>
</html>
\ No newline at end of file
from django.test import TestCase
# NOTE: all unit tests return an error saying a queryset is needed; lecture 16 says this is fine
class IngredientsListPageTest(TestCase):
def test_ingredients_list_page_returns_correct_html(self):
response = self.client.get('/ingredients_list_page')
self.assertTemplateUsed(response, 'ingredients_list.html')
# NOTE: returns error saying queryset is needed; lecture 16 says this is fine
\ No newline at end of file
class IngredientsDetailPageTest(TestCase):
def test_ingredients_detail_page_returns_correct_html(self):
response = self.client.get('/ingredients_detail_page')
self.assertTemplateUsed(response, 'ingredients_detail.html')
class IngredientsUpdateFormPageTest(TestCase):
def test_ingredients_update_form_page_returns_correct_html(self):
response = self.client.get('/ingredients_update_form_page')
self.assertTemplateUsed(response, 'ingredients_update_form.html')
class IngredientsCreateFormPageTest(TestCase):
def test_ingredients_create_form_page_returns_correct_html(self):
response = self.client.get('/ingredients_create_form_page')
self.assertTemplateUsed(response, 'ingredients_create_form.html')
\ No newline at end of file
from django.conf.urls import url
from .views import IngredientsListView
from .views import IngredientsListView, IngredientsDetailView, IngredientsUpdateFormView, IngredientsCreateFormView
urlpatterns = [
url(r'^ingredients_list_page$', IngredientsListView.as_view(), name='Ingredients_List_View'),
url(r'^ingredients_detail_page$', IngredientsDetailView.as_view(), name='Ingredients_Detail_View'),
url(r'^ingredients_update_form_page$', IngredientsUpdateFormView.as_view(), name='Ingredients_Update_Form_View'),
url(r'^ingredients_create_form_page$', IngredientsCreateFormView.as_view(), name='Ingredients_Create_Form_View'),
]
\ No newline at end of file
from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import UpdateView, CreateView
class IngredientsListView(ListView):
model = None
\ No newline at end of file
model = None
class IngredientsDetailView(DetailView):
model = None
class IngredientsUpdateFormView(UpdateView):
model = None
template_name_suffix = '_update_form'
class IngredientsCreateFormView(CreateView):
model = None
template_name_suffix = '_create_form'
\ No newline at end of file
......@@ -17,14 +17,41 @@ class NewVisitorTest(unittest.TestCase):
# self.assertIn('The Good Place FroYo Shop', self.browser.title)
# employee opens ingredients list page and checks title
#def test_can_open_ingredients_list_page(self):
# self.browser.get('http://localhost:8000/ingredients_list_page')
# self.assertIn('Ingredients - List', self.browser.title)
# self.assertEqual(
# 'http://localhost:8000/ingredients_list_page',
# self.browser.getCurrentUrl()
# )
# NOTE: unit testing this returns an error because a queryset is not implemented
# NOTE: unit testing ALL tests returns an error because a queryset is not implemented
def test_can_open_ingredients_list_page(self):
self.browser.get('http://localhost:8000/ingredients_list_page')
self.assertIn('Ingredients - List', self.browser.title)
self.assertEqual(
'http://localhost:8000/ingredients_list_page',
self.browser.getCurrentUrl()
)
# employee opens ingredients detail page and checks title
def test_can_open_ingredients_detail_page(self):
self.browser.get('http://localhost:8000/ingredients_detail_page')
self.assertIn('Ingredients - Detail', self.browser.title)
self.assertEqual(
'http://localhost:8000/ingredients_detail_page',
self.browser.getCurrentUrl()
)
# employee opens ingredients update form page and checks title
def test_can_open_ingredients_update_form_page(self):
self.browser.get('http://localhost:8000/ingredients_update_form_page')
self.assertIn('Ingredients - Update', self.browser.title)
self.assertEqual(
'http://localhost:8000/ingredients_update_form_page',
self.browser.getCurrentUrl()
)
# employee opens ingredients create form page and checks title
def test_can_open_ingredients_create_form_page(self):
self.browser.get('http://localhost:8000/ingredients_create_form_page')
self.assertIn('Ingredients - Create', self.browser.title)
self.assertEqual(
'http://localhost:8000/ingredients_create_form_page',
self.browser.getCurrentUrl()
)
if __name__ == '__main__':
unittest.main(warnings = 'ignore')
\ No newline at end of file
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