Revised Functional Test, and made necessart changes.

parent 90a550ca
......@@ -3,4 +3,10 @@
<head>
<title>The Good Place FroYo Shop</title>
</head>
<h1>The Good Place FroYo Shop</h1>
<ul>
<li><a href="http://localhost:8000/orders" id="orders-list">Orders</a></li>
<li><a href="http://localhost:8000/recipes" id="recipes-list">Recipes</a></li>
<li><a href="http://localhost:8000/ingredients" id="ingredients-list">Ingredients</a></li>
</ul>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Ingredients - Create</title>
</head>
<body>
<h1>Ingredients - Create</h1>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Ingredients - Detail</title>
</head>
<body>
<h1>Ingredients - Detail</h1>
</body>
</html>
......@@ -3,4 +3,13 @@
<head>
<title>Ingredients - List</title>
</head>
<body>
<h1>Ingredients - List</h1>
<ul>
<li><a href="http://localhost:8000/ingredients/detail" id="ingredients-detail">Detail</a></li>
<li><a href="http://localhost:8000/ingredients/update_form" id="ingredients-update-form">Update Form</a></li>
<li><a href="http://localhost:8000/ingredients/create_form" id="ingredients-create-form">Create Form</a></li>
</ul>
<a href="http://localhost:8000/" id="home">Return to Home Page</a>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Ingredients - Update</title>
</head>
<body>
<h1>Ingredients - Update</h1>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Orders - Create</title>
</head>
<body>
<h1>Orders - Create</h1>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Orders - Detail</title>
</head>
<body>
<h1>Orders - Detail</h1>
</body>
</html>
......@@ -3,4 +3,13 @@
<head>
<title>Orders - List</title>
</head>
<body>
<h1>Orders - List</h1>
<ul>
<li><a href="http://localhost:8000/orders/detail" id="orders-detail">Detail</a></li>
<li><a href="http://localhost:8000/orders/update_form" id="orders-update-form">Update Form</a></li>
<li><a href="http://localhost:8000/orders/create_form" id="orders-create-form">Create Form</a></li>
</ul>
<a href="http://localhost:8000/" id="home">Return to Home Page</a>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Orders - Update</title>
</head>
<body>
<h1>Orders - Update</h1>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Recipes - Create</title>
</head>
<body>
<h1>Recipes - Create</h1>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Recipes - Detail</title>
</head>
<body>
<h1>Recipes - Detail</h1>
</body>
</html>
......@@ -3,4 +3,13 @@
<head>
<title>Recipes - List</title>
</head>
<body>
<h1>Recipes - List</h1>
<ul>
<li><a href="http://localhost:8000/recipes/detail" id="recipes-detail">Detail</a></li>
<li><a href="http://localhost:8000/recipes/update_form" id="recipes-update-form">Update Form</a></li>
<li><a href="http://localhost:8000/recipes/create_form" id="recipes-create-form">Create Form</a></li>
</ul>
<a href="http://localhost:8000/" id="home">Return to Home Page</a>
</body>
</html>
......@@ -3,4 +3,7 @@
<head>
<title>Recipes - Update</title>
</head>
<body>
<h1>Recipes - Update</h1>
</body>
</html>
from selenium import webdriver
import unittest
import time
from selenium import webdriver
class NewVisitorTest(unittest.TestCase):
......@@ -10,61 +11,186 @@ class NewVisitorTest(unittest.TestCase):
def tearDown(self):
self.browser.quit()
def test_can_go_to_home(self):
#Wishing to have a look at all the available options, our employee goes to the home page.
def test_can_add_orders(self):
# Wishing to have a look at all the available options, our employee goes to the home page.
self.browser.get('http://localhost:8000/')
#Hoping he isn't wrong, he looks at the page title to double check.
# He looks at the page title to double check.
self.assertIn('The Good Place FroYo Shop', self.browser.title)
def test_can_add_orders(self):
#A customer orders a certain froyo. An employee processes the order, verifying that they are on the correct page.
# Then, he sees a series of links. He clicks on 'Orders'.
orders = self.browser.find_element_by_id('orders-list')
orders.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/orders',
self.browser.current_url
)
# He sees several links and click the corresponding ones that would allow him to create and update. He is returned to the orders page after each success.
orders_create = self.browser.find_element_by_id('orders-create-form')
orders_create.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/orders/create_form',
self.browser.current_url
)
self.browser.get('http://localhost:8000/orders')
self.assertIn('Orders - List', self.browser.title)
#They add the order into the list after seeing a button in the page that would allow them to do so.
self.browser.get('http://localhost:8000/orders/create_form')
self.assertIn('Orders - Create', self.browser.title)
self.browser.get('http://localhost:8000/orders/update_form')
self.assertIn('Orders - Update', self.browser.title)
orders_update = self.browser.find_element_by_id('orders-update-form')
orders_update.click()
time.sleep(1)
def test_can_display_order_details(self):
#Having already gone to the list of orders, the employee clicks on a specific order to display its details.
self.browser.get('http://localhost:8000/orders/detail')
self.assertIn('Orders - Detail', self.browser.title)
self.assertEqual(
'http://localhost:8000/orders/update_form',
self.browser.current_url
)
self.browser.get('http://localhost:8000/orders')
# The employee goes to the order he added in order to verify it.
orders_detail = self.browser.find_element_by_id('orders-detail')
orders_detail.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/orders/detail',
self.browser.current_url
)
self.browser.get('http://localhost:8000/orders')
# Following that, he returns to the home page.
back = self.browser.find_element_by_id('home')
back.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/',
self.browser.current_url
)
def can_add_ingredients(self):
# Noticing a deficiency in ingredients, the employee goes to add more.
self.browser.get('http://localhost:8000/')
# He clicks on 'Ingredients'.
ingredients = self.browser.find_element_by_id('ingredients-list')
ingredients.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients',
self.browser.current_url
)
# He sees several links and click the corresponding ones that would allow him to create and update. He is returned to the orders page after each success.
ingredients_create = self.browser.find_element_by_id('ingredients-create-form')
ingredients_create.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients/create_form',
self.browser.current_url
)
self.browser.get('http://localhost:8000/ingredients')
ingredients_update = self.browser.find_element_by_id('ingredients-update-form')
ingredients_update.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients/update_form',
self.browser.current_url
)
def test_can_add_recipes(self):
#The employees came up with a new recipe, deciding to add it to the list. One of them goes to the list.
self.browser.get('http://localhost:8000/recipes')
self.assertIn('Recipes - List', self.browser.title)
#They add the recipe into the list after seeing a button in the page that would allow them to do so.
self.browser.get('http://localhost:8000/recipes/create_form')
self.assertIn('Recipes - Create', self.browser.title)
self.browser.get('http://localhost:8000/recipes/update_form')
self.assertIn('Recipes - Update', self.browser.title)
def test_can_display_recipe_details(self):
#Having already gone to the list of recipes, the employee clicks on a specific recipe to display its details.
self.browser.get('http://localhost:8000/recipes/detail')
self.assertIn('Recipes - Detail', self.browser.title)
def test_can_add_ingredients(self):
#One of the employees, a deliveryman, arrive with a package of dry ice. Wishing to keep track of the change,
#They add it to the list.
self.browser.get('http://localhost:8000/ingredients')
self.assertIn('Ingredients - List', self.browser.title)
#After some looking, they find a button that would allow them to add their ingredients.
self.browser.get('http://localhost:8000/ingredients/create_form')
self.assertIn('Ingredients - Create', self.browser.title)
self.browser.get('http://localhost:8000/ingredients/update_form')
self.assertIn('Ingredients - Update', self.browser.title)
def test_can_display_ingredient_details(self):
#The employee wanted to know how much dry ice they currently have, so they click on the entry.
self.browser.get('http://localhost:8000/ingredients/detail')
self.assertIn('Ingredients - Detail', self.browser.title)
# The employee goes to the order he added in order to verify it.
ingredients_detail = self.browser.find_element_by_id('ingredients-detail')
ingredients_detail.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients/detail',
self.browser.current_url
)
self.browser.get('http://localhost:8000/ingredients')
# Following that, he returns to the home page.
back = self.browser.find_element_by_id('home')
back.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/',
self.browser.current_url
)
def can_add_recipes(self):
# Having come up with a new idea, the employee goes to add his favourite recipe.
self.browser.get('http://localhost:8000/')
# He clicks on 'Recipes'.
recipes = self.browser.find_element_by_id('recipes-list')
recipes.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes',
self.browser.current_url
)
# He sees several links and click the corresponding ones that would allow him to create and update. He is returned to the orders page after each success.
recipes_create = self.browser.find_element_by_id('recipes-create-form')
recipes_create.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes/create_form',
self.browser.current_url
)
self.browser.get('http://localhost:8000/recipes')
recipes_update = self.browser.find_element_by_id('recipes-update-form')
recipes_update.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes/update_form',
self.browser.current_url
)
self.browser.get('http://localhost:8000/recipes')
# The employee goes to the order he added in order to verify it.
recipes_detail = self.browser.find_element_by_id('recipes-detail')
recipes_detail.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes/detail',
self.browser.current_url
)
self.browser.get('http://localhost:8000/recipes')
# Following that, he returns to the home page.
back = self.browser.find_element_by_id('home')
back.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/',
self.browser.current_url
)
if __name__ == '__main__':
unittest.main(warnings='ignore')
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