Fakultas Ilmu Komputer UI

Commit 817297be authored by Rahmania Astrid Mochtar's avatar Rahmania Astrid Mochtar
Browse files

fixed unit test

parent d3cb834b
Pipeline #28232 passed with stages
in 37 minutes and 29 seconds
......@@ -34,10 +34,6 @@ class HomePageTest(TestCase):
expected_html
)
# def test_home_page_can_save_a_POST_request(self):
# response = self.client.post('/', data={'item_text': 'A new list item'})
# self.assertRedirects(response, '/lists/the-only-list-in-the-world/')
class ListViewTest(TestCase):
def test_uses_list_template(self):
......@@ -46,17 +42,19 @@ class ListViewTest(TestCase):
self.assertTemplateUsed(response, 'list.html')
def test_displays_only_items_for_that_list(self):
correct_list = List.objects.create()
correct_list = List.objects.create(title="list")
create_items(2, correct_list)
other_list = List.objects.create()
other_list = List.objects.create(title="other list")
Item.objects.create(text='other list item 1', list=other_list)
Item.objects.create(text='other list item 2', list=other_list)
response = self.client.get(f'/lists/{correct_list.id}/')
self.assertContains(response, 'list')
self.assertContains(response, 'itemey 1')
self.assertContains(response, 'itemey 2')
self.assertContains(response, 'other list')
self.assertNotContains(response, 'other list item 1')
self.assertNotContains(response, 'other list item 2')
......@@ -66,14 +64,6 @@ class ListViewTest(TestCase):
response = self.client.get(f'/lists/{correct_list.id}/')
self.assertEqual(response.context['list'], correct_list)
# def test_automated_comment_if_list_empty(self):
# response = self.client.get('/')
# self.assertIn(
# 'yey, waktunya berlibur',
# response.content.decode()
# )
def test_automated_comment_if_list_less_than_5(self):
list_ = List.objects.create()
create_items(2, list_)
......
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