Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Collection of Practice
2019
1606823475-practice
Commits
d37a4134
Commit
d37a4134
authored
Dec 21, 2019
by
Muhammad Ilham Peruzzi
Browse files
[RED] add unit test for delete feature
parent
4dfa0ba5
Changes
1
Hide whitespace changes
Inline
Side-by-side
lists/tests/test_views.py
View file @
d37a4134
...
...
@@ -4,7 +4,7 @@ from django.http import HttpRequest
from
django.template.loader
import
render_to_string
from
lists.models
import
Item
,
List
from
lists.views
import
home_page
,
about_me
,
view_list
from
lists.views
import
home_page
,
about_me
,
view_list
,
delete_todo
class
ListViewTest
(
TestCase
):
...
...
@@ -46,4 +46,12 @@ class ListViewTest(TestCase):
other_list
=
List
.
objects
.
create
()
correct_list
=
List
.
objects
.
create
()
response
=
self
.
client
.
get
(
'/lists/%d/'
%
(
correct_list
.
id
,))
self
.
assertEqual
(
response
.
context
[
'list'
],
correct_list
)
\ No newline at end of file
self
.
assertEqual
(
response
.
context
[
'list'
],
correct_list
)
def
test_todo_can_be_deleted
(
self
):
self
.
client
.
post
(
'/lists/new'
,
data
=
{
'item_text'
:
'A new list item'
})
self
.
assertEqual
(
Item
.
objects
.
count
(),
1
)
new_item
=
Item
.
objects
.
first
()
new_list
=
List
.
objects
.
first
()
delete_todo
(
self
,
new_list
.
id
,
new_item
.
id
)
self
.
assertEqual
(
Item
.
objects
.
count
(),
0
)
Write
Preview
Supports
Markdown
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