Fakultas Ilmu Komputer UI

Commit d37a4134 authored by Muhammad Ilham Peruzzi's avatar Muhammad Ilham Peruzzi
Browse files

[RED] add unit test for delete feature

parent 4dfa0ba5
......@@ -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)
Supports Markdown
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