Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CSCI 40 Midterm Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lance Michael O. Co
CSCI 40 Midterm Project
Commits
60547524
Commit
60547524
authored
Mar 17, 2020
by
Lance Michael O. Co
😢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the Functional Test
parent
0af9bf8d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
311 additions
and
15 deletions
+311
-15
ingredients.html
froyo/templates/ingredients.html
+0
-0
orders.html
froyo/templates/orders.html
+0
-0
recipes.html
froyo/templates/recipes.html
+0
-0
tests.py
froyo/tests.py
+22
-1
urls.py
froyo/urls.py
+9
-2
views.py
froyo/views.py
+13
-1
functional_test.py
functional_test.py
+267
-11
No files found.
froyo/templates/ingredients.html
0 → 100644
View file @
60547524
froyo/templates/orders.html
0 → 100644
View file @
60547524
froyo/templates/recipes.html
0 → 100644
View file @
60547524
froyo/tests.py
View file @
60547524
#froyo/tests
from
django.test
import
TestCase
#home page tests
class
HomePageTest
(
TestCase
):
def
test_uses_home_template
(
self
):
...
...
@@ -9,6 +9,27 @@ class HomePageTest(TestCase):
self
.
assertTemplateUsed
(
response
,
'home.html'
)
class
IngredientsHomePageTest
(
TestCase
):
def
test_uses_home_template
(
self
):
response
=
self
.
client
.
get
(
'/ingredients'
)
self
.
assertTemplateUsed
(
response
,
'ingredients.html'
)
class
RecipesHomePageTest
(
TestCase
):
def
test_uses_home_template
(
self
):
response
=
self
.
client
.
get
(
'/recipes'
)
self
.
assertTemplateUsed
(
response
,
'recipes.html'
)
class
OrdersHomePageTest
(
TestCase
):
def
test_uses_home_template
(
self
):
response
=
self
.
client
.
get
(
'/orders'
)
self
.
assertTemplateUsed
(
response
,
'orders.html'
)
#ingredients tests
class
IngredientsListTest
(
TestCase
):
...
...
froyo/urls.py
View file @
60547524
#froyo/urls
from
django.conf.urls
import
url
from
.views
import
HomeView
,
IngredientsList
,
IngredientsDetail
,
IngredientsUpdate
,
IngredientsCreate
,
RecipesList
,
RecipesDetail
,
RecipesUpdate
,
RecipesCreate
,
OrdersList
,
OrdersDetail
,
OrdersUpdate
,
OrdersCreate
from
.views
import
(
HomeView
,
IngredientsHomeView
,
RecipesHomeView
,
OrdersHomeView
,
IngredientsList
,
IngredientsDetail
,
IngredientsUpdate
,
IngredientsCreate
,
RecipesList
,
RecipesDetail
,
RecipesUpdate
,
RecipesCreate
,
OrdersList
,
OrdersDetail
,
OrdersUpdate
,
OrdersCreate
)
urlpatterns
=
[
url
(
r'^$'
,
HomeView
,
name
=
'home_page'
),
#home urls
url
(
r'^$'
,
HomeView
.
as_view
(),
name
=
'home_page'
),
url
(
r'^ingredients$'
,
IngredientsHomeView
.
as_view
(),
name
=
'ingredients'
),
url
(
r'^recipes$'
,
RecipesHomeView
.
as_view
(),
name
=
'recipes'
),
url
(
r'^orders$'
,
OrdersHomeView
.
as_view
(),
name
=
'orders'
),
#ingredients urls
url
(
r'^ingredients/list$'
,
IngredientsList
.
as_view
(),
name
=
'ingredients-list'
),
...
...
froyo/views.py
View file @
60547524
...
...
@@ -5,11 +5,23 @@ from django.views.generic.detail import DetailView
from
django.views.generic.edit
import
UpdateView
from
django.views.generic.edit
import
CreateView
#Home Pages
class
HomeView
(
TemplateView
):
template_name
=
"home.html"
class
IngredientsHomeView
(
TemplateView
):
template_name
=
"ingredients.html"
class
RecipesHomeView
(
TemplateView
):
template_name
=
"recipes.html"
class
OrdersHomeView
(
TemplateView
):
template_name
=
"orders.html"
#Ingredients
class
IngredientsList
(
ListView
):
template_name
=
"ingredients_list.html"
...
...
functional_test.py
View file @
60547524
...
...
@@ -20,32 +20,288 @@ class NewVisitorTest(unittest.TestCase):
self
.
assertIn
(
'The Good Place FroYo Shop'
,
self
.
browser
.
title
)
#user sees 3 links (orders, ingredients, recipes)
self
.
browser
.
get
(
'http://localhost:8000/ingredient
s'
)
self
.
browser
.
get
(
'http://localhost:8000/recipes'
)
self
.
browser
.
get
(
'http://localhost:8000/order
s'
)
orders
=
self
.
browser
.
find_element_by_id
(
'order
s'
)
ingredients
=
self
.
browser
.
find_element_by_id
(
'ingredients'
)
recipes
=
self
.
browser
.
find_element_by_id
(
'recipe
s'
)
def
test_can_see_and_use_ingredients_page
(
self
):
#user goes to orders page
self
.
browser
.
get
(
'http://localhost:8000/ingredients'
)
#user clicks on ingredients page
self
.
browser
.
get
(
'http://localhost:8000'
)
ingredients
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/ingredients'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's at the right page
self
.
assertIn
(
'Orders'
,
self
.
browser
.
title
)
self
.
assertIn
(
'Ingredients'
,
self
.
browser
.
title
)
#user sees 4 links all dealing with what he can do with ingredients.
#After each success he is returned to the home page of the ingredients.
ingredients_create
=
self
.
browser
.
find_element_by_id
(
'ingredients-create-form'
)
ingredients_detail
=
self
.
browser
.
find_element_by_id
(
'ingredients-detail'
)
ingredients_list
=
self
.
browser
.
find_element_by_id
(
'ingredients-list'
)
ingredients_update
=
self
.
browser
.
find_element_by_id
(
'ingredients-update-form'
)
#user also sees a link to take him back to the home page
back
=
self
.
browser
.
find_element_by_id
(
'back_to_home_page'
)
#user checks list of ingredients
ingredients_list
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/ingredients/list'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Ingredients - List'
.
self
.
browser
.
title
)
#satisfied, user goes back to the ingredients page
self
.
browser
.
get
(
'http://localhost:8000/ingredients'
)
#seeing that an ingredient is missing, user creates an ingredient
ingredients_create
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/ingredients/create_form'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Ingredients - Create'
.
self
.
browser
.
title
)
#satisfied, user goes back to the ingredients page
self
.
browser
.
get
(
'http://localhost:8000/ingredients'
)
#user then checks the details of the ingredient
ingredients_detail
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/ingredients/detail'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Ingredients - Detail'
.
self
.
browser
.
title
)
#satisfied, user goes back to the ingredients page
self
.
browser
.
get
(
'http://localhost:8000/ingredients'
)
#noticing something is missing, the user updates the ingredient
ingredients_update
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/ingredients/update'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Ingredients - Update'
.
self
.
browser
.
title
)
#satisfied, user goes back to the ingredients page
self
.
browser
.
get
(
'http://localhost:8000/ingredients'
)
#finished checking the ingredients, the user then returns to the home page
back
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/'
,
self
.
browser
.
current_url
)
def
test_can_see_and_use_recipes_page
(
self
):
#user goes to orders page
self
.
browser
.
get
(
'http://localhost:8000/recipes'
)
#user clicks on recipes page
self
.
browser
.
get
(
'http://localhost:8000'
)
recipes
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/recipes'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's at the right page
self
.
assertIn
(
'Orders'
,
self
.
browser
.
title
)
self
.
assertIn
(
'Recipes'
,
self
.
browser
.
title
)
#user sees 4 links all dealing with what he can do with recipes.
#After each success he is returned to the home page of the recipes.
recipes_create
=
self
.
browser
.
find_element_by_id
(
'recipes-create-form'
)
recipes_detail
=
self
.
browser
.
find_element_by_id
(
'recipes-detail'
)
recipes_list
=
self
.
browser
.
find_element_by_id
(
'recipes-list'
)
recipes_update
=
self
.
browser
.
find_element_by_id
(
'recipes-update-form'
)
#user also sees a link to take him back to the home page
back
=
self
.
browser
.
find_element_by_id
(
'back_to_home_page'
)
#user checks list of recipes
recipes_list
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/recipes/list'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Recipes - List'
.
self
.
browser
.
title
)
#satisfied, user goes back to the recipes page
self
.
browser
.
get
(
'http://localhost:8000/recipes'
)
#seeing that an recipe is missing, user creates an recipe
recipes_create
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/recipes/create_form'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Recipes - Create'
.
self
.
browser
.
title
)
#satisfied, user goes back to the recipes page
self
.
browser
.
get
(
'http://localhost:8000/recipes'
)
#user then checks the details of the recipe
recipes_detail
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/recipes/detail'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Recipes - Detail'
.
self
.
browser
.
title
)
#satisfied, user goes back to the recipes page
self
.
browser
.
get
(
'http://localhost:8000/recipes'
)
#noticing something is missing, the user updates the recipe
recipes_update
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/recipes/update'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Recipes - Update'
.
self
.
browser
.
title
)
#satisfied, user goes back to the recipes page
self
.
browser
.
get
(
'http://localhost:8000/recipes'
)
#finished checking the recipes, the user then returns to the home page
back
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/'
,
self
.
browser
.
current_url
)
def
test_can_see_and_use_orders_page
(
self
):
#user goes to orders page
self
.
browser
.
get
(
'http://localhost:8000/orders'
)
#user clicks on orders page
self
.
browser
.
get
(
'http://localhost:8000'
)
orders
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/orders'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's at the right page
self
.
assertIn
(
'Orders'
,
self
.
browser
.
title
)
#user sees 4 links all dealing with what he can do with orders.
#After each success he is returned to the home page of the orders.
orders_create
=
self
.
browser
.
find_element_by_id
(
'orders-create-form'
)
orders_detail
=
self
.
browser
.
find_element_by_id
(
'orders-detail'
)
orders_list
=
self
.
browser
.
find_element_by_id
(
'orders-list'
)
orders_update
=
self
.
browser
.
find_element_by_id
(
'orders-update-form'
)
#user also sees a link to take him back to the home page
back
=
self
.
browser
.
find_element_by_id
(
'back_to_home_page'
)
#user checks list of orders
orders_list
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/orders/list'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Orders - List'
.
self
.
browser
.
title
)
#satisfied, user goes back to the orders page
self
.
browser
.
get
(
'http://localhost:8000/orders'
)
#seeing that an order is missing, user creates an order
orders_create
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/orders/create_form'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Orders - Create'
.
self
.
browser
.
title
)
#satisfied, user goes back to the orders page
self
.
browser
.
get
(
'http://localhost:8000/orders'
)
#user then checks the details of the order
orders_detail
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/orders/detail'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Orders - Detail'
.
self
.
browser
.
title
)
#satisfied, user goes back to the orders page
self
.
browser
.
get
(
'http://localhost:8000/orders'
)
#noticing something is missing, the user updates the order
orders_update
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/orders/update'
,
self
.
browser
.
current_url
)
#user checks page title to ensure he's in the right page
self
.
assertIn
(
'Orders - Update'
.
self
.
browser
.
title
)
#satisfied, user goes back to the orders page
self
.
browser
.
get
(
'http://localhost:8000/orders'
)
#finished checking the orders, the user then returns to the home page
back
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/'
,
self
.
browser
.
current_url
)
if
__name__
=
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment