Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Midterm-Project-186050-Columbres-v2
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
Alysha Columbres
Midterm-Project-186050-Columbres-v2
Commits
8035d270
Commit
8035d270
authored
Mar 19, 2020
by
Alysha Columbres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created and tested the other three views for the ingredients model
parent
2e3eef31
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
12 deletions
+96
-12
ingredients_create_form.html
froyo/templates/ingredients_create_form.html
+6
-0
ingredients_detail.html
froyo/templates/ingredients_detail.html
+6
-0
ingredients_update_form.html
froyo/templates/ingredients_update_form.html
+6
-0
tests.py
froyo/tests.py
+22
-2
urls.py
froyo/urls.py
+4
-1
views.py
froyo/views.py
+17
-1
functional_test.py
functional_test.py
+35
-8
No files found.
froyo/templates/ingredients_create_form.html
0 → 100644
View file @
8035d270
<!DOCTYPE html>
<html>
<head>
<title>
Ingredients - Create
</title>
</head>
</html>
\ No newline at end of file
froyo/templates/ingredients_detail.html
0 → 100644
View file @
8035d270
<!DOCTYPE html>
<html>
<head>
<title>
Ingredients - Detail
</title>
</head>
</html>
\ No newline at end of file
froyo/templates/ingredients_update_form.html
0 → 100644
View file @
8035d270
<!DOCTYPE html>
<html>
<head>
<title>
Ingredients - Update
</title>
</head>
</html>
\ No newline at end of file
froyo/tests.py
View file @
8035d270
from
django.test
import
TestCase
from
django.test
import
TestCase
# NOTE: all unit tests return an error saying a queryset is needed; lecture 16 says this is fine
class
IngredientsListPageTest
(
TestCase
):
class
IngredientsListPageTest
(
TestCase
):
def
test_ingredients_list_page_returns_correct_html
(
self
):
def
test_ingredients_list_page_returns_correct_html
(
self
):
response
=
self
.
client
.
get
(
'/ingredients_list_page'
)
response
=
self
.
client
.
get
(
'/ingredients_list_page'
)
self
.
assertTemplateUsed
(
response
,
'ingredients_list.html'
)
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
class
IngredientsDetailPageTest
(
TestCase
):
def
test_ingredients_detail_page_returns_correct_html
(
self
):
response
=
self
.
client
.
get
(
'/ingredients_detail_page'
)
self
.
assertTemplateUsed
(
response
,
'ingredients_detail.html'
)
class
IngredientsUpdateFormPageTest
(
TestCase
):
def
test_ingredients_update_form_page_returns_correct_html
(
self
):
response
=
self
.
client
.
get
(
'/ingredients_update_form_page'
)
self
.
assertTemplateUsed
(
response
,
'ingredients_update_form.html'
)
class
IngredientsCreateFormPageTest
(
TestCase
):
def
test_ingredients_create_form_page_returns_correct_html
(
self
):
response
=
self
.
client
.
get
(
'/ingredients_create_form_page'
)
self
.
assertTemplateUsed
(
response
,
'ingredients_create_form.html'
)
\ No newline at end of file
froyo/urls.py
View file @
8035d270
from
django.conf.urls
import
url
from
django.conf.urls
import
url
from
.views
import
IngredientsListView
from
.views
import
IngredientsListView
,
IngredientsDetailView
,
IngredientsUpdateFormView
,
IngredientsCreateFormView
urlpatterns
=
[
urlpatterns
=
[
url
(
r'^ingredients_list_page$'
,
IngredientsListView
.
as_view
(),
name
=
'Ingredients_List_View'
),
url
(
r'^ingredients_list_page$'
,
IngredientsListView
.
as_view
(),
name
=
'Ingredients_List_View'
),
url
(
r'^ingredients_detail_page$'
,
IngredientsDetailView
.
as_view
(),
name
=
'Ingredients_Detail_View'
),
url
(
r'^ingredients_update_form_page$'
,
IngredientsUpdateFormView
.
as_view
(),
name
=
'Ingredients_Update_Form_View'
),
url
(
r'^ingredients_create_form_page$'
,
IngredientsCreateFormView
.
as_view
(),
name
=
'Ingredients_Create_Form_View'
),
]
]
\ No newline at end of file
froyo/views.py
View file @
8035d270
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
UpdateView
,
CreateView
class
IngredientsListView
(
ListView
):
class
IngredientsListView
(
ListView
):
model
=
None
model
=
None
\ No newline at end of file
class
IngredientsDetailView
(
DetailView
):
model
=
None
class
IngredientsUpdateFormView
(
UpdateView
):
model
=
None
template_name_suffix
=
'_update_form'
class
IngredientsCreateFormView
(
CreateView
):
model
=
None
template_name_suffix
=
'_create_form'
\ No newline at end of file
functional_test.py
View file @
8035d270
...
@@ -17,14 +17,41 @@ class NewVisitorTest(unittest.TestCase):
...
@@ -17,14 +17,41 @@ class NewVisitorTest(unittest.TestCase):
# 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):
# NOTE: unit testing ALL tests returns an error because a queryset is not implemented
# self.browser.get('http://localhost:8000/ingredients_list_page')
def
test_can_open_ingredients_list_page
(
self
):
# self.assertIn('Ingredients - List', self.browser.title)
self
.
browser
.
get
(
'http://localhost:8000/ingredients_list_page'
)
# self.assertEqual(
self
.
assertIn
(
'Ingredients - List'
,
self
.
browser
.
title
)
# 'http://localhost:8000/ingredients_list_page',
self
.
assertEqual
(
# self.browser.getCurrentUrl()
'http://localhost:8000/ingredients_list_page'
,
# )
self
.
browser
.
getCurrentUrl
()
# NOTE: unit testing this returns an error because a queryset is not implemented
)
# employee opens ingredients detail page and checks title
def
test_can_open_ingredients_detail_page
(
self
):
self
.
browser
.
get
(
'http://localhost:8000/ingredients_detail_page'
)
self
.
assertIn
(
'Ingredients - Detail'
,
self
.
browser
.
title
)
self
.
assertEqual
(
'http://localhost:8000/ingredients_detail_page'
,
self
.
browser
.
getCurrentUrl
()
)
# employee opens ingredients update form page and checks title
def
test_can_open_ingredients_update_form_page
(
self
):
self
.
browser
.
get
(
'http://localhost:8000/ingredients_update_form_page'
)
self
.
assertIn
(
'Ingredients - Update'
,
self
.
browser
.
title
)
self
.
assertEqual
(
'http://localhost:8000/ingredients_update_form_page'
,
self
.
browser
.
getCurrentUrl
()
)
# employee opens ingredients create form page and checks title
def
test_can_open_ingredients_create_form_page
(
self
):
self
.
browser
.
get
(
'http://localhost:8000/ingredients_create_form_page'
)
self
.
assertIn
(
'Ingredients - Create'
,
self
.
browser
.
title
)
self
.
assertEqual
(
'http://localhost:8000/ingredients_create_form_page'
,
self
.
browser
.
getCurrentUrl
()
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
(
warnings
=
'ignore'
)
unittest
.
main
(
warnings
=
'ignore'
)
\ No newline at end of file
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