Commit 1cc22fd8 authored by Li Niko M. Arceo's avatar Li Niko M. Arceo 🦈

functional test added, templates redesigned

parent 5d77ac55
<html>
<title>Home</title>
<head>
<title>The Good Place FroYo Shop - Home</title>
</head>
<body>
<h1>The Good Place FroYo Shop - Home</h1>
<dl>
<dt>Ingredients</dt>
<dd>List</dd>
<dd>Detail</dd>
<dd>Update Form</dd>
<dd>Create Form</dd>
<dt>Recipes</dt>
<dd>List</dd>
<dd>Detail</dd>
<dd>Update Form</dd>
<dd>Create Form</dd>
<dt>Orders</dt>
<dd>List</dd>
<dd>Detail</dd>
<dd>Update Form</dd>
<dd>Create Form</dd>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Ingredients - Create</title>
</head>
<body>
<h1>Ingredients - Create</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Ingredients - Detail</title>
</head>
<body>
<h1>Ingredients - Detail</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Ingredients - List</title>
</head>
<body>
<h1>Ingredients - List</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Ingredients - Update</title>
</head>
<body>
<h1>Ingredients - Update</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Orders - Create</title>
</head>
<body>
<h1>Orders - Create</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Orders - Detail</title>
</head>
<body>
<h1>Orders - Detail</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Orders - List</title>
</head>
<body>
<h1>Orders - List</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Orders - Update</title>
</head>
<body>
<h1>Orders - Update</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Recipes - Create</title>
</head>
<body>
<h1>Recipes - Create</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Recipes - Detail</title>
</head>
<body>
<h1>Recipes - Detail</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Recipes - List</title>
</head>
<body>
<h1>Recipes - List</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>Recipes - Update</title>
</head>
<body>
<h1>Recipes - Update</h1>
<dl>
<dt>Back to Home</dt>
</dl>
</body>
</html>
\ No newline at end of file
from django.test import TestCase
class HomePageTest(TestCase):
class ViewsTest(TestCase):
def test_uses_home_template(self):
response = self.client.get('/')
self.assertTemplateUsed(response,'home.html')
#ingredients tests
class IngredientsListTest(TestCase):
def test_uses_ingredients_list_template(self):
response = self.client.get('/ingredients/list')
self.assertTemplateUsed(response,'ingredients_list.html')
class IngredientsDetailTest(TestCase):
def test_uses_ingredients_detail_template(self):
response = self.client.get('/ingredients/detail')
self.assertTemplateUsed(response,'ingredients_detail.html')
class IngredientsUpdateTest(TestCase):
def test_uses_ingredients_update_template(self):
response = self.client.get('/ingredients/update')
self.assertTemplateUsed(response,'ingredients_update_form.html')
class IngredientsCreateTest(TestCase):
def test_uses_ingredients_create_template(self):
response = self.client.get('/ingredients/create')
self.assertTemplateUsed(response,'ingredients_create_form.html')
#recipes tests
class RecipesListTest(TestCase):
def test_uses_recipes_list_template(self):
response = self.client.get('/recipes/list')
self.assertTemplateUsed(response,'recipes_list.html')
class RecipesDetailTest(TestCase):
def test_uses_recipes_detail_template(self):
response = self.client.get('/recipes/detail')
self.assertTemplateUsed(response,'recipes_detail.html')
class RecipesUpdateTest(TestCase):
def test_uses_recipes_update_template(self):
response = self.client.get('/recipes/update')
self.assertTemplateUsed(response,'recipes_update_form.html')
class RecipesCreateTest(TestCase):
def test_uses_recipes_create_template(self):
response = self.client.get('/recipes/create')
self.assertTemplateUsed(response,'recipes_create_form.html')
#orders tests
class OrdersListTest(TestCase):
def test_uses_orders_list_template(self):
response = self.client.get('/orders/list')
self.assertTemplateUsed(response,'orders_list.html')
class OrdersDetailTest(TestCase):
def test_uses_orders_detail_template(self):
response = self.client.get('/orders/detail')
self.assertTemplateUsed(response,'orders_detail.html')
class OrdersUpdateTest(TestCase):
def test_uses_orders_update_template(self):
response = self.client.get('/orders/update')
self.assertTemplateUsed(response,'orders_update_form.html')
class OrdersCreateTest(TestCase):
def test_uses_orders_create_template(self):
response = self.client.get('/orders/create')
self.assertTemplateUsed(response,'orders_create_form.html')
\ No newline at end of file
from selenium import webdriver
import unittest
import time
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def tearDown(self):
self.browser.quit()
def test_can_display_a_heroes_list_and_more_information_per_hero(self):
browser.get('http://localhost:8000')
# check homepage title
self.assertIn('The Good Place FroYo Shop - Home', self.browser.title)
# check to see list of each model, having 4 links for each view underneath
model_list = self.browser.find_element_by_id('model_list')
self.assertEqual(
'ul',
model_list.tag_name
)
# check if each link leads to its corresponding view
#ingredients views
link = self.browser.find_element_by_id('ingredients-list')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients/list',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('ingredients-detail')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients/detail',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('ingredients-update')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients/update',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('ingredients-create')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/ingredients/create',
self.browser.getCurrentUrl()
)
#recipes views
link = self.browser.find_element_by_id('recipes-list')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes/list',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('recipes-detail')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes/detail',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('recipes-update')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes/update',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('recipes-create')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/recipes/create',
self.browser.getCurrentUrl()
)
#orders views
link = self.browser.find_element_by_id('orders-list')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/orders/list',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('orders-detail')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/orders/detail',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('orders-update')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/orders/update',
self.browser.getCurrentUrl()
)
link = self.browser.find_element_by_id('orders-create')
link.click()
time.sleep(1)
self.assertEqual(
'http://localhost:8000/orders/create',
self.browser.getCurrentUrl()
)
# check page title of each view
self.browser.get('http://localhost:8000/ingredients/list')
self.assertIn('Ingredients - List', self.browser.title)
self.browser.get('http://localhost:8000/ingredients/detail')
self.assertIn('Ingredients - Details', self.browser.title)
self.browser.get('http://localhost:8000/ingredients/update')
self.assertIn('Ingredients - Update', self.browser.title)
self.browser.get('http://localhost:8000/ingredients/create')
self.assertIn('Ingredients - Create', self.browser.title)
self.browser.get('http://localhost:8000/recipes/list')
self.assertIn('Recipes - List', self.browser.title)
self.browser.get('http://localhost:8000/recipes/detail')
self.assertIn('Recipes - Details', self.browser.title)
self.browser.get('http://localhost:8000/recipes/update')
self.assertIn('Recipes - Update', self.browser.title)
self.browser.get('http://localhost:8000/recipes/create')
self.assertIn('Recipes - Create', self.browser.title)
self.browser.get('http://localhost:8000/orders/list')
self.assertIn('Orders - List', self.browser.title)
self.browser.get('http://localhost:8000/orders/detail')
self.assertIn('Orders - Details', self.browser.title)
self.browser.get('http://localhost:8000/orders/update')
self.assertIn('Orders - Update', self.browser.title)
self.browser.get('http://localhost:8000/orders/create')
self.assertIn('Orders - Create', self.browser.title)
# check if back to homepage button works
back_button = self.browser.find_element_by_id('back_button')
self.assertEqual(
'Back to Home',
back_button.text
)
back_button.click()
time.sleep(1)
self.fail('Finish the test!')
\ No newline at end of file
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