Created views and tests for the list, detail, update, and create functions of...

Created views and tests for the list, detail, update, and create functions of the models, created urls.py of the froyo app, added froyo to settings.py, and modified functional tests.
parent 2d0c93bf
from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest
# Create your tests here.
#ingredients model
class IngredientsListTest(TestCase):
def test_ingredients_list_page_returns_correct(self):
response = self.client.get('/ingredients/list')
self.assertTemplateUsed(response, 'ingredients_list.html')
class IngredientsDetailTest(TestCase):
def test_ingredients_detail_page_returns_correct(self):
response = self.client.get('/ingredients/detail')
self.assertTemplateUsed(response, 'ingredients_detail.html')
class IngredientsUpdateTest(TestCase):
def test_ingredients_update_page_returns_correct(self):
response = self.client.get('/ingredients/update')
self.assertTemplateUsed(response, 'ingredients_update_form.html')
class IngredientsCreateTest(TestCase):
def test_ingredients_create_page_returns_correct(self):
response = self.client.get('/ingredients/create')
self.assertTemplateUsed(response, 'ingredients_create_form.html')
#recipes model
class RecipesListTest(TestCase):
def test_recipes_list_page_returns_correct(self):
response = self.client.get('/recipes/create')
self.assertTemplateUsed(response, 'recipes_list.html')
class RecipessDetailTest(TestCase):
def test_recipes_detail_page_returns_correct(self):
response = self.client.get('/recipes/detail')
self.assertTemplateUsed(response, 'recipes_detail.html')
class RecipesUpdateTest(TestCase):
def test_recipes_update_page_returns_correct(self):
response = self.client.get('/recipes/update')
self.assertTemplateUsed(response, 'recipes_update_form.html')
class RecipesCreateTest(TestCase):
def test_recipes_create_page_returns_correct(self):
response = self.client.get('/recipes/create')
self.assertTemplateUsed(response, 'recipes_create_form.html')
#orders model
class OrdersListTest(TestCase):
def test_orders_list_page_returns_correct(self):
response = self.client.get('/orders/list')
self.assertTemplateUsed(response, 'orders_list.html')
class OrdersDetailTest(TestCase):
def test_orders_detail_page_returns_correct(self):
response = self.client.get('/orders/detail')
self.assertTemplateUsed(response, 'orders_detail.html')
class OrdersUpdateTest(TestCase):
def test_recipes_update_page_returns_correct(self):
response = self.client.get('/orders/update')
self.assertTemplateUsed(response, 'orders_update_form.html')
class OrdersCreateTest(TestCase):
def test_orders_create_page_returns_correct(self):
response = self.client.get('/orders/create')
self.assertTemplateUsed(response, 'orders_create_form.html')
\ No newline at end of file
from django.conf.urls import url
from .views import HomeTemplateView, CloudTemplateView, JesterTemplateView, SunfloweyTemplateView
urlpatterns = [
url(r'^$', HomeTemplateView.as_view(), name='home'),
url(r'^hero/cloud/$', CloudTemplateView.as_view(), name='detail_cloud'),
url(r'^hero/jester/$', JesterTemplateView.as_view(), name='detail_jester'),
url(r'^hero/sunflowey/$', SunfloweyTemplateView.as_view(), name='detail_sunflowey'),
]
from django.conf.urls import url
from .views import IngredientsListView, IngredientsDetailView, IngredientsUpdateView, IngredientsCreateView, RecipesListView, RecipesDetailView, RecipesUpdateView, RecipesCreateView, OrdersListView, OrdersDetailView, OrdersUpdateView, OrdersCreateView
urlpatterns = [
url(r'^ingredients/list/$', IngredientsListView.as_view(), name='ingredients_list'),
url(r'^ingredients/detail/$', IngredientsDetailView.as_view(), name='ingredients_detail'),
url(r'^ingredients/update/$', IngredientsUpdateView.as_view(), name='ingredients_update_form'),
url(r'^ingredients/create/$', IngredientsCreateView.as_view(), name='ingredients_create_form'),
url(r'^recipes/list/$', RecipesListView.as_view(), name='recipes_list'),
url(r'^recipes/detail/$', RecipesDetailView.as_view(), name='recipes_detail'),
url(r'^recipes/update/$', RecipesUpdateView.as_view(), name='recipes_update_form'),
url(r'^recipes/create/$', RecipesCreateView.as_view(), name='recipes_create_form'),
url(r'^orders/list/$', OrdersListView.as_view(), name='orders_list'),
url(r'^orders/detail/$', OrdersDetailView.as_view(), name='orders_detail'),
url(r'^orders/update/$', OrdersUpdateView.as_view(), name='orders_update_form'),
url(r'^orders/create/$', OrdersCreateView.as_view(), name='orders_create_form'),
]
\ No newline at end of file
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic.base import TemplateView
#ingredients model
class IngredientsListView(TemplateView):
template_name = 'ingredients_list.html'
class IngredientsDetailView(TemplateView):
template_name = 'ingredients_detail.html'
class IngredientsUpdateView(TemplateView):
template_name = 'ingredients_update_form.html'
class IngredientsUpdateView(TemplateView):
template_name = 'ingredients_create_form.html'
#recipes model
class RecipesListView(TemplateView):
template_name = 'recipes_list.html'
class RecipesDetailView(TemplateView):
template_name = 'recipes_detail.html'
class RecipesUpdateView(TemplateView):
template_name = 'recipes_update_form.html'
class RecipesCreateView(TemplateView):
template_name = 'recipes_create_form.html'
#orders model
class OrdersListView(TemplateView):
template_name = 'orders_list.html'
class OrdersDetailView(TemplateView):
template_name = 'orders_detail.html'
class OrdersUpdateView(TemplateView):
template_name = 'orders_update_form.html'
class OrdersCreateView(TemplateView):
template_name = 'orders_create_form.html'
# Create your views here.
......@@ -11,6 +11,84 @@ class NewVisitorTest(unittest.TestCase):
def tearDown(self):
self.browser.quit()
#ingredients model
def test_can_start_and_retrieve_ingredient_list(self):
self.browser.get('http://localhost:8000/ingredients/list')
self.assertIn('Ingredients - List', self.browser.title)
ingredients_list = self.browser.find_element_by_id('ingredients_list')
self.assertEqual(
'ul',
ingredients_list.tag_name
)
def test_can_display_ingredients_detail(self):
self.browser.get('http://localhost:8000/ingredients/detail')
self.assertIn('Ingredients - Detail', self.browser.title)
def test_can_update_ingredients(self):
self.browser.get('http://localhost:8000/ingredients/update')
self.assertIn('Ingredients - Update', self.browser.title)
def test_can_create_ingredients(self):
self.browser.get('http://localhost:8000/ingredients/create')
self.assertIn('Ingredients - Create', self.browser.title)
#self.assertIn('', self.browser.find_element_by_id('new_ingredient_name').text)
#self.assertIn('', self.browser.find_element_by_id('new_recipe_quantity').text)
#recipes model
def test_can_start_and_retrieve_recipe_list(self):
self.browser.get('http://localhost:8000/recipes/list')
self.assertIn('Recipes - List', self.browser.title)
recipes_list = self.browser.find_element_by_id('recipes_list')
self.assertEqual(
'ul',
recipes_list.tag_name
)
def test_can_display_recipes_detail(self):
self.browser.get('http://localhost:8000/recipes/detail')
self.assertIn('Recipes - Detail', self.browser.title)
def test_can_update_recipes(self):
self.browser.get('http://localhost:8000/recipes/update')
self.assertIn('Recipes - Update', self.browser.title)
def test_can_create_Recipes(self):
self.browser.get('http://localhost:8000/recipes/create')
self.assertIn('Recipes - Create', self.browser.title)
#self.assertIn('', self.browser.find_element_by_id('new_recipe_name').text)
#self.assertIn('', self.browser.find_element_by_id('new_recipe_ingredient_name').text)
#self.assertIn('', self.browser.find_element_by_id('new_recipe_quantity').text)
#orders model
def test_can_start_and_retrieve_orders_list(self):
self.browser.get('http://localhost:8000/orders/list')
self.assertIn('Orders - List', self.browser.title)
recipes_list = self.browser.find_element_by_id('orders_list')
self.assertEqual(
'ul',
orders_list.tag_name
)
def test_can_display_orders_detail(self):
self.browser.get('http://localhost:8000/orders/detail')
self.assertIn('Orders - Detail', self.browser.title)
def test_can_update_orders(self):
self.browser.get('http://localhost:8000/orders/update')
self.assertIn('Orders - Update', self.browser.title)
def test_can_create_orders(self):
self.browser.get('http://localhost:8000/orders/create')
self.assertIn('Orders - Create', self.browser.title)
#self.assertIn('', self.browser.find_element_by_id('new_customer_name').text)
#self.assertIn('', self.browser.find_element_by_id('new_size').text)
#self.assertIn('', self.browser.find_element_by_id('new_base_recipe').text)
#self.assertIn('',self.browser.find_element_by_id('new_customization').text)
if __name__ == '__main__':
unittest.main(warnings='ignore')
\ No newline at end of file
......@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'froyo'
]
MIDDLEWARE = [
......
......@@ -13,9 +13,10 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
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
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', include('froyo.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