Commit 18ed47af authored by cj0125's avatar cj0125

Added URLs. Added functional tests.

parent d2319e9a
"""thegoodplace URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
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 .views import IngredientsCreateFormView, IngredientsDetailView, IngredientsListView, IngredientsUpdateFormView, OrdersCreateFormView, OrdersDetailView, OrdersListView, OrdersUpdateFormView, RecipesCreateFormView, RecipesDetailView, RecipesListView, RecipesUpdateFormView
urlpatterns = [
url(r'^ingredients_create_form$',IngredientsCreateFormView.as_view(),name='ICF'),
url(r'^ingredients_detail$',IngredientsDetailView.as_view(),name='ID'),
url(r'^ingredients_list$', IngredientsListView.as_view(), name='IL'),
url(r'^ingredients_update_form$',IngredientsUpdateFormView.as_view(),name='IUF'),
url(r'^orders_create_form$',OrdersCreateFormView.as_view(),name='OCF'),
url(r'^orders_detail$',OrdersDetailView.as_view(),name='OD'),
url(r'^orders_list$',OrdersListView.as_view(),name='OL'),
url(r'^orders_update_form$',OrdersUpdateFormView.as_view(),name='OUF'),
url(r'^recipes_create_form$',RecipesCreateFormView.as_view(),name='RCF'),
url(r'^recipes_detail$',RecipesDetailView.as_view(),name='RD'),
url(r'^recipes_list$',RecipesListView.as_view(),name='RL'),
url(r'^recipes_update_form$',RecipesUpdateFormView.as_view(),name='RUF'),
]
import unittest
from selenium import webdriver
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def tearDown(self):
self.browser.quit()
def test_display_ICF(self):
self.browser.get('http://localhost:8000/ingredients_create_form')
self.assertIn('Ingredients - Create Form', self.browser.title)
self.assertIn('http://localhost:8000/ingredients_create_form', self.browser.current_url)
def test_display_ID(self):
self.browser.get('http://localhost:8000/ingredients_detail')
self.assertIn('Ingredients - Detail', self.browser.title)
self.assertIn('http://localhost:8000/ingredients_detail', self.browser.current_url)
def test_display_IL(self):
self.browser.get('http://localhost:8000/ingredients_list')
self.assertIn('Ingredients - List', self.browser.title)
self.assertIn('http://localhost:8000/ingredients_list', self.browser.current_url)
def test_display_IUF(self):
self.browser.get('http://localhost:8000/ingredients_update_form')
self.assertIn('Ingredients - Update Form', self.browser.title)
self.assertIn('http://localhost:8000/ingredients_update_form', self.browser.current_url)
def test_display_OCF(self):
self.browser.get('http://localhost:8000/orders_create_form')
self.assertIn('Orders - Create Form', self.browser.title)
self.assertIn('http://localhost:8000/orders_create_form', self.browser.current_url)
def test_display_OD(self):
self.browser.get('http://localhost:8000/orders_detail')
self.assertIn('Orders - Detail', self.browser.title)
self.assertIn('http://localhost:8000/orders_detail', self.browser.current_url)
def test_display_OL(self):
self.browser.get('http://localhost:8000/orders_list')
self.assertIn('Orders - List', self.browser.title)
self.assertIn('http://localhost:8000/orders_list', self.browser.current_url)
def test_display_OUF(self):
self.browser.get('http://localhost:8000/orders_update_form')
self.assertIn('Orders - Update Form', self.browser.title)
self.assertIn('http://localhost:8000/orders_update_form', self.browser.current_url)
def test_display_RCF(self):
self.browser.get('http://localhost:8000/recipes_create_form')
self.assertIn('Recipes - Create Form', self.browser.title)
self.assertIn('http://localhost:8000/recipes_create_form', self.browser.current_url)
def test_display_RD(self):
self.browser.get('http://localhost:8000/recipes_detail')
self.assertIn('Recipes - Detail', self.browser.title)
self.assertIn('http://localhost:8000/recipes_detail', self.browser.current_url)
def test_display_RL(self):
self.browser.get('http://localhost:8000/recipes_list')
self.assertIn('Recipes - List', self.browser.title)
self.assertIn('http://localhost:8000/recipes_list', self.browser.current_url)
def test_display_RUF(self):
self.browser.get('http://localhost:8000/recipes_update_form')
self.assertIn('Recipes - Update Form', self.browser.title)
self.assertIn('http://localhost:8000/recipes_update_form', self.browser.current_url)
self.fail('Finish the test!')
if __name__ == 'main':
unittest.main(warnings = 'ignore')
......@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'froyo'
]
MIDDLEWARE = [
......
......@@ -18,4 +18,5 @@ 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