Commit f742b982 authored by John Carlos Sanil's avatar John Carlos Sanil

Merge branch 'user-story-functional-test' into 'develop'

Created a user story and made the functional test

See merge request !5
parents b38f9fb0 9ae6fc67
......@@ -8,8 +8,467 @@ class NewVisitorTest(unittest.TestCase):
def tearDown(self):
self.browser.quit()
def test_can_go_to_site(self):
self.browser.get('http://localhost:8000')
def test_can_go_home_page(self):
# 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__':
......
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