Commit 2e3eef31 authored by Alysha Columbres's avatar Alysha Columbres

Tested the list view for the ingredients model

parent 517575c0
<!DOCTYPE html>
<html>
<head>
<title>Ingredients - List</title>
</head>
</html>
\ No newline at end of file
from django.test import TestCase from django.test import TestCase
# Create your tests here.
class IngredientsListPageTest(TestCase):
def test_ingredients_list_page_returns_correct_html(self):
response = self.client.get('/ingredients_list_page')
self.assertTemplateUsed(response, 'ingredients_list.html')
# NOTE: returns error saying queryset is needed; lecture 16 says this is fine
\ No newline at end of file
from django.conf.urls import url
from .views import IngredientsListView
urlpatterns = [
url(r'^ingredients_list_page$', IngredientsListView.as_view(), name='Ingredients_List_View'),
]
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
# Create your views here. from django.views.generic.list import ListView
class IngredientsListView(ListView):
model = None
\ No newline at end of file
...@@ -12,18 +12,19 @@ class NewVisitorTest(unittest.TestCase): ...@@ -12,18 +12,19 @@ class NewVisitorTest(unittest.TestCase):
self.browser.quit() self.browser.quit()
# employee opens website and sees the title # employee opens website and sees the title
def test_can_open_website(self): #def test_can_open_website(self):
self.browser.get('http://localhost:8000') # self.browser.get('http://localhost:8000')
self.assertIn('The Good Place FroYo Shop', self.browser.title) # self.assertIn('The Good Place FroYo Shop', self.browser.title)
# employee opens ingredients list page and checks title # employee opens ingredients list page and checks title
def test_can_open_ingredients_list_page(self): #def test_can_open_ingredients_list_page(self):
self.browser.get('http://localhost:8000/ingredients_list_page') # self.browser.get('http://localhost:8000/ingredients_list_page')
self.assertIn('Ingredients - List', self.browser.title) # self.assertIn('Ingredients - List', self.browser.title)
self.assertEqual( # self.assertEqual(
'http://localhost:8000/ingredients_list_page', # 'http://localhost:8000/ingredients_list_page',
self.browser.getCurrentUrl() # self.browser.getCurrentUrl()
) # )
# NOTE: unit testing this returns an error because a queryset is not implemented
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(warnings = 'ignore') unittest.main(warnings = 'ignore')
\ No newline at end of file
...@@ -13,9 +13,10 @@ Including another URLconf ...@@ -13,9 +13,10 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include 1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
""" """
from django.conf.urls import url from django.conf.urls import url, include
from django.contrib import admin from django.contrib import admin
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'', include('froyo.urls'))
] ]
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