Commit 541d04aa authored by Alysha Columbres's avatar Alysha Columbres

Created and tested the views for the recipes model

parent 8035d270
<!DOCTYPE html>
<html>
<head>
<title>Recipes - Create</title>
</head>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Recipes - Detail</title>
</head>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Recipes - List</title>
</head>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Recipes - Update</title>
</head>
</html>
\ No newline at end of file
...@@ -26,4 +26,32 @@ class IngredientsCreateFormPageTest(TestCase): ...@@ -26,4 +26,32 @@ class IngredientsCreateFormPageTest(TestCase):
def test_ingredients_create_form_page_returns_correct_html(self): def test_ingredients_create_form_page_returns_correct_html(self):
response = self.client.get('/ingredients_create_form_page') response = self.client.get('/ingredients_create_form_page')
self.assertTemplateUsed(response, 'ingredients_create_form.html') self.assertTemplateUsed(response, 'ingredients_create_form.html')
\ No newline at end of file
class RecipesListPageTest(TestCase):
def test_recipes_list_page_returns_correct_html(self):
response = self.client.get('/recipes_list_page')
self.assertTemplateUsed(response, 'recipes_list.html')
class RecipesDetailPageTest(TestCase):
def test_recipes_detail_page_returns_correct_html(self):
response = self.client.get('/recipes_detail_page')
self.assertTemplateUsed(response, 'recipes_detail.html')
class RecipesUpdateFormPageTest(TestCase):
def test_recipes_update_form_page_returns_correct_html(self):
response = self.client.get('/recipes_update_form_page')
self.assertTemplateUsed(response, 'recipes_update_form.html')
class RecipesCreateFormPageTest(TestCase):
def test_recipes_create_form_page_returns_correct_html(self):
response = self.client.get('/recipes_create_form_page')
self.assertTemplateUsed(response, 'recipes_create_form.html')
\ No newline at end of file
from django.conf.urls import url from django.conf.urls import url
from .views import IngredientsListView, IngredientsDetailView, IngredientsUpdateFormView, IngredientsCreateFormView from .views import IngredientsListView, IngredientsDetailView, IngredientsUpdateFormView, IngredientsCreateFormView, RecipesListView, RecipesDetailView, RecipesUpdateFormView, RecipesCreateFormView
urlpatterns = [ urlpatterns = [
url(r'^ingredients_list_page$', IngredientsListView.as_view(), name='Ingredients_List_View'), 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_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_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'), url(r'^ingredients_create_form_page$', IngredientsCreateFormView.as_view(), name='Ingredients_Create_Form_View'),
url(r'^recipes_list_page$', RecipesListView.as_view(), name='Recipes_List_View'),
url(r'^recipes_detail_page$', RecipesDetailView.as_view(), name='Recipes_Detail_View'),
url(r'^recipes_update_form_page$', RecipesUpdateFormView.as_view(), name='Recipes_Update_Form_View'),
url(r'^recipes_create_form_page$', RecipesCreateFormView.as_view(), name='Recipes_Create_Form_View'),
] ]
\ No newline at end of file
...@@ -18,5 +18,23 @@ class IngredientsUpdateFormView(UpdateView): ...@@ -18,5 +18,23 @@ class IngredientsUpdateFormView(UpdateView):
class IngredientsCreateFormView(CreateView): class IngredientsCreateFormView(CreateView):
model = None
template_name_suffix = '_create_form'
class RecipesListView(ListView):
model = None
class RecipesDetailView(DetailView):
model = None
class RecipesUpdateFormView(UpdateView):
model = None
template_name_suffix = '_update_form'
class RecipesCreateFormView(CreateView):
model = None model = None
template_name_suffix = '_create_form' template_name_suffix = '_create_form'
\ No newline at end of file
...@@ -53,5 +53,41 @@ class NewVisitorTest(unittest.TestCase): ...@@ -53,5 +53,41 @@ class NewVisitorTest(unittest.TestCase):
self.browser.getCurrentUrl() self.browser.getCurrentUrl()
) )
# employee opens recipes list page and checks title
def test_can_open_recipes_list_page(self):
self.browser.get('http://localhost:8000/recipes_list_page')
self.assertIn('Recipes - List', self.browser.title)
self.assertEqual(
'http://localhost:8000/recipes_list_page',
self.browser.getCurrentUrl()
)
# employee opens recipes detail page and checks title
def test_can_open_recipes_detail_page(self):
self.browser.get('http://localhost:8000/recipes_detail_page')
self.assertIn('Recipes - Detail', self.browser.title)
self.assertEqual(
'http://localhost:8000/recipes_detail_page',
self.browser.getCurrentUrl()
)
# employee opens recipes update form page and checks title
def test_can_open_recipes_update_form_page(self):
self.browser.get('http://localhost:8000/recipes_update_form_page')
self.assertIn('Recipes - Update', self.browser.title)
self.assertEqual(
'http://localhost:8000/recipes_update_form_page',
self.browser.getCurrentUrl()
)
# employee opens recipes create form page and checks title
def test_can_open_recipes_create_form_page(self):
self.browser.get('http://localhost:8000/recipes_create_form_page')
self.assertIn('Recipes - Create', self.browser.title)
self.assertEqual(
'http://localhost:8000/recipes_create_form_page',
self.browser.getCurrentUrl()
)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(warnings = 'ignore') 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