Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CSCI40-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
Andrea Tsai
CSCI40-Midterm-Project
Commits
0b2f51e9
Commit
0b2f51e9
authored
Mar 18, 2020
by
littleredpanda14
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created a functional test
parent
975b07de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
+100
-0
functional_test.py
functional_test.py
+100
-0
No files found.
functional_test.py
0 → 100644
View file @
0b2f51e9
import
unittest
import
time
from
selenium
import
webdriver
class
WelcomeToTheGoodPlaceTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
browser
=
webdriver
.
Firefox
()
def
tearDown
(
self
):
self
.
browser
.
quit
()
def
test_can_summon_janet_with_all_froyo_info
(
self
):
# Eleanor wants to find out more about the Froyo Shop
# She calls on The Good Place's omniscient database Janet to find out more.
self
.
browser
.
get
(
'http://localhost:8000'
)
# She summons Janet, and is met with the response (header and title)
# 'Hi. My name is Janet.'
self
.
assertIn
(
'Hi. My name is Janet.'
,
self
.
browser
.
title
)
#Janet gives Eleanor all the information she has on the Froyo shop which includes:
#Ingredients, Recipes and Orders
froyo
=
self
.
browser
.
find_element_by_id
(
'janet'
)
self
.
assertEqual
(
'ul'
,
froyo
.
tag_name
)
# When she asks for information about the Ingredients, Janet sends her to another page
# which has the list of ingredients.
ingredients
=
self
.
browser
.
find_element_by_id
(
'ingredients_list'
)
ingredients
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/froyo/ingredients'
,
self
.
browser
.
getCurrentUrl
()
)
# It is called the 'Ingredients - List' Janet tells her.
self
.
assertIn
(
'Ingredients - List'
,
self
.
browser
.
title
)
# Eleanor asks Janet to give more specific details on each item on the list
# so Janet sends her to a different page depending on the ingredient Eleanor has selected
ingredients_detail
=
self
.
browser
.
find_element_by_id
(
'almonds'
)
ingredients_detail
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/froyo/ingredients/almonds'
,
self
.
browser
.
getCurrentUrl
()
)
# Eleanor wants to update the ingredient information because she can. So she asks Janet
# to give her an ingredients update form.
ingredients_update_form
=
self
.
browser
.
find_element_by_id
(
'ingredients_update'
)
ingredients_update_form
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/froyo/ingredients/update'
,
self
.
browser
.
getCurrentUrl
()
)
# Eleanor then decides that she wants to create new ingredients for the inventory.
# She asks Janet to provide an ingredients create form for her to use.
ingredients_create_form
=
self
.
browser
.
find_element_by_id
(
'ingredients_create'
)
ingredients_create_form
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/froyo/ingredients/create'
,
self
.
browser
.
getCurrentUrl
()
)
# While she browsing through any specific janet page (either ingredients, recipes or orders),
# she sees a button labeled "Back to Janet".
# She clicks this and is sent back to Janet.
back_button
=
self
.
browser
.
find_element_by_id
(
'back_button'
)
self
.
assertEqual
(
'Back to Janet'
,
back_button
.
text
)
back_button
.
click
()
time
.
sleep
(
1
)
self
.
assertEqual
(
'http://localhost:8000/froyo/ingredients'
,
self
.
browser
.
getCurrentUrl
()
)
self
.
fail
(
'Finish the test!'
)
if
__name__
==
'__main__'
:
unittest
.
main
(
warnings
=
'ignore'
)
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