Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
csci40_midterms
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
John Carlos Sanil
csci40_midterms
Commits
9ae6fc67
Commit
9ae6fc67
authored
Mar 21, 2020
by
Carlowsss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created a user story and made the functional test
parent
b38f9fb0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
461 additions
and
2 deletions
+461
-2
functional_tests.py
functional_tests.py
+461
-2
No files found.
functional_tests.py
View file @
9ae6fc67
...
@@ -8,8 +8,467 @@ class NewVisitorTest(unittest.TestCase):
...
@@ -8,8 +8,467 @@ class NewVisitorTest(unittest.TestCase):
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
browser
.
quit
()
self
.
browser
.
quit
()
def
test_can_go_to_site
(
self
):
def
test_can_go_home_page
(
self
):
self
.
browser
.
get
(
'http://localhost:8000'
)
# Eleanor is now promoted to be the manager of their FroYo Shop.
# She is introduced to the web app the shop uses to manage orders.
# She goes to the site which directs her to the home page.
self
.
browser
.
get
(
'http://localhost:8000/'
)
# She notices the page title and header mention
# "The Good Place FroYo Shop"
self
.
assertIn
(
'The Good Place FroYo Shop'
,
self
.
browser
.
title
)
# She then sees a list of three items: ingredients, recipes, and orders.
main_list
=
self
.
browser
.
find_element_by_id
(
'main_list'
)
self
.
assertEqual
(
'ul'
,
main_list
.
tag_name
)
def
test_can_access_ingredients_and_use_its_features
(
self
):
# Eleanor decides to check the available ingredients of the shop.
# She clicks 'ingredients'. She is sent to a different page with a list of ingredients.
# She also notices the title and header, "Ingredients - List"
ingredients_list
=
self
.
browser
.
find_element_by_id
(
'ingredients_list'
)
ingredients_list
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_list'
,
self
.
browser
.
getCurrentUrl
()
)
self
.
assertIn
(
'Ingredients - List'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Ingredients - List'
,
header
.
text
)
# She sees the list of ingredients and three buttons.
# The three buttons state "Details", "Update", and "Create"
# She tries to click each button
# First she tries to click "Details"
detail_button
=
self
.
browser
.
find_element_by_id
(
'detail_button'
)
self
.
assertEqual
(
'Details'
,
detail_button
.
text
)
detail_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_detail'
,
self
.
browser
.
getCurrentUrl
()
)
# She sees the details of the ingredients.
# She also notices the title and header, "Ingredients - Detail"
self
.
assertIn
(
'Ingredients - Detail'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Ingredients - Detail'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Ingredients
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_list'
,
self
.
browser
.
getCurrentUrl
()
)
# Then she tries to click "Update"
update_button
=
self
.
browser
.
find_element_by_id
(
'update_button'
)
self
.
assertEqual
(
'Update'
,
update_button
.
text
)
update_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_update_form'
,
self
.
browser
.
getCurrentUrl
()
)
# She notices the title and header, "Ingredients - Update"
self
.
assertIn
(
'Ingredients - Update'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Ingredients - Update'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Ingredients
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_list'
,
self
.
browser
.
getCurrentUrl
()
)
# Finally, she tries to click "Create"
create_button
=
self
.
browser
.
find_element_by_id
(
'create_button'
)
self
.
assertEqual
(
'Create'
,
create_button
.
text
)
create_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_create_form'
,
self
.
browser
.
getCurrentUrl
()
)
# She notices the title and header, "Ingredients - Create"
self
.
assertIn
(
'Ingredients - Create'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Ingredients - Create'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Ingredients
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_list'
,
self
.
browser
.
getCurrentUrl
()
)
# She has now gone through everything.
# She sees a back to home button and decides to go to the home page.
back_home_button
=
self
.
browser
.
find_element_by_id
(
'back_home_button'
)
self
.
assertEqual
(
'Back To Home'
,
back_home_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_list'
,
self
.
browser
.
getCurrentUrl
()
)
def
test_can_access_recipes_and_use_its_features
(
self
):
# Eleanor decides to check the recipes of the FroYo
# She clicks 'Recipes'. She is sent to a different page with a list of ingredients.
# She also notices the title and header, "Recipes - List"
recipes_list
=
self
.
browser
.
find_element_by_id
(
'recipes_list'
)
recipes_list
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/recipes_list'
,
self
.
browser
.
getCurrentUrl
()
)
self
.
assertIn
(
'Recipes - List'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Recipes - List'
,
header
.
text
)
# She sees the list of Recipes and three buttons.
# The three buttons state "Details", "Update", and "Create"
# She tries to click each button
# First she tries to click "Details"
detail_button
=
self
.
browser
.
find_element_by_id
(
'detail_button'
)
self
.
assertEqual
(
'Details'
,
detail_button
.
text
)
detail_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/recipes_detail'
,
self
.
browser
.
getCurrentUrl
()
)
# She sees the details of the Recipes.
# She also notices the title and header, "Recipes - Detail"
self
.
assertIn
(
'Recipes - Detail'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Recipes - Detail'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Recipes
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/recipes_list'
,
self
.
browser
.
getCurrentUrl
()
)
# Then she tries to click "Update"
update_button
=
self
.
browser
.
find_element_by_id
(
'update_button'
)
self
.
assertEqual
(
'Update'
,
update_button
.
text
)
update_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/recipes_update_form'
,
self
.
browser
.
getCurrentUrl
()
)
# She notices the title and header, "Recipes - Update"
self
.
assertIn
(
'Recipes - Update'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Recipes - Update'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Recipes
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/recipes_list'
,
self
.
browser
.
getCurrentUrl
()
)
# Finally, she tries to click "Create"
create_button
=
self
.
browser
.
find_element_by_id
(
'create_button'
)
self
.
assertEqual
(
'Create'
,
create_button
.
text
)
create_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/recipes_create_form'
,
self
.
browser
.
getCurrentUrl
()
)
# She notices the title and header, "Recipes - Create"
self
.
assertIn
(
'Recipes - Create'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Recipes - Create'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Recipes
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/recipes_list'
,
self
.
browser
.
getCurrentUrl
()
)
# She has now gone through everything.
# She sees a back to home button and decides to go to the home page.
back_home_button
=
self
.
browser
.
find_element_by_id
(
'back_home_button'
)
self
.
assertEqual
(
'Back To Home'
,
back_home_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_list'
,
self
.
browser
.
getCurrentUrl
()
)
def
test_can_access_orders_and_use_its_features
(
self
):
# Eleanor decides to check the Orders of FroYo Customers
# She clicks 'Orders'. She is sent to a different page with a list of ingredients.
# She also notices the title and header, "Orders - List"
orders_list
=
self
.
browser
.
find_element_by_id
(
'orders_list'
)
orders_list
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/orders_list'
,
self
.
browser
.
getCurrentUrl
()
)
self
.
assertIn
(
'Orders - List'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Orders - List'
,
header
.
text
)
# She sees the list of Orders and three buttons.
# The three buttons state "Details", "Update", and "Create"
# She tries to click each button
# First she tries to click "Details"
detail_button
=
self
.
browser
.
find_element_by_id
(
'detail_button'
)
self
.
assertEqual
(
'Details'
,
detail_button
.
text
)
detail_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/orders_detail'
,
self
.
browser
.
getCurrentUrl
()
)
# She sees the details of the Orders.
# She also notices the title and header, "Orders - Detail"
self
.
assertIn
(
'Orders - Detail'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Orders - Detail'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Recipes
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/orders_list'
,
self
.
browser
.
getCurrentUrl
()
)
# Then she tries to click "Update"
update_button
=
self
.
browser
.
find_element_by_id
(
'update_button'
)
self
.
assertEqual
(
'Update'
,
update_button
.
text
)
update_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/orders_update_form'
,
self
.
browser
.
getCurrentUrl
()
)
# She notices the title and header, "Orders - Update"
self
.
assertIn
(
'Orders - Update'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Orders - Update'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Orders
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/orders_list'
,
self
.
browser
.
getCurrentUrl
()
)
# Finally, she tries to click "Create"
create_button
=
self
.
browser
.
find_element_by_id
(
'create_button'
)
self
.
assertEqual
(
'Create'
,
create_button
.
text
)
create_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/orders_create_form'
,
self
.
browser
.
getCurrentUrl
()
)
# She notices the title and header, "Orders - Create"
self
.
assertIn
(
'Orders - Create'
,
self
.
browser
.
title
)
header
=
self
.
browser
.
find_element_by_id
(
'header'
)
self
.
assertEqual
(
'Orders - Create'
,
header
.
text
)
# She sees a back button, she clicks it to go back to the Orders
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/orders_list'
,
self
.
browser
.
getCurrentUrl
()
)
# She has now gone through everything.
# She sees a back to home button and decides to go to the home page.
back_home_button
=
self
.
browser
.
find_element_by_id
(
'back_home_button'
)
self
.
assertEqual
(
'Back To Home'
,
back_home_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'https://localhost:8000/ingredients_list'
,
self
.
browser
.
getCurrentUrl
()
)
if
__name__
==
'__main__'
:
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