7.10.2 Adjusting new_list to the New World (w/ bug fix)
This commit is contained in:
parent
434e66e0ae
commit
29124d8fcd
@ -18,16 +18,17 @@ class NewListTest(TestCase):
|
|||||||
|
|
||||||
def test_redirects_after_POST(self):
|
def test_redirects_after_POST(self):
|
||||||
response = self.client.post('/lists/new', data={'item_text': 'A new list item'})
|
response = self.client.post('/lists/new', data={'item_text': 'A new list item'})
|
||||||
self.assertRedirects(response=response, expected_url='/lists/the-only-list-in-the-world/')
|
new_list = List.objects.first()
|
||||||
|
self.assertRedirects(response=response, expected_url=f'/lists/{new_list.id}/')
|
||||||
|
|
||||||
class ListViewTest(TestCase):
|
class ListViewTest(TestCase):
|
||||||
|
|
||||||
def test_uses_list_template(self):
|
def test_uses_list_template(self):
|
||||||
list_ = List.objects.create()
|
list_ = List.objects.create()
|
||||||
response = self.client.get('/lists/{list_.id}/')
|
response = self.client.get(f'/lists/{list_.id}/')
|
||||||
self.assertTemplateUsed(response=response, template_name='list.html')
|
self.assertTemplateUsed(response=response, template_name='list.html')
|
||||||
|
|
||||||
def test_displays_all_items(self):
|
def test_displays_only_items_for_that_list(self):
|
||||||
correct_list = List.objects.create()
|
correct_list = List.objects.create()
|
||||||
Item.objects.create(text="itemey 1", list=correct_list)
|
Item.objects.create(text="itemey 1", list=correct_list)
|
||||||
Item.objects.create(text="itemey 2", list=correct_list)
|
Item.objects.create(text="itemey 2", list=correct_list)
|
||||||
@ -36,12 +37,12 @@ class ListViewTest(TestCase):
|
|||||||
Item.objects.create(text="other list item 2", list=other_list)
|
Item.objects.create(text="other list item 2", list=other_list)
|
||||||
|
|
||||||
|
|
||||||
response = self.client.get('/lists/{correct_list.id}/')
|
response = self.client.get(f'/lists/{correct_list.id}/')
|
||||||
|
|
||||||
self.assertContains(response, 'itemey 1')
|
self.assertContains(response, 'itemey 1')
|
||||||
self.assertContains(response, 'itemey 2')
|
self.assertContains(response, 'itemey 2')
|
||||||
self.assertContains(response=response, text='other list item 1')
|
self.assertNotContains(response=response, text='other list item 1')
|
||||||
self.assertContains(response=response, text='other list item 2')
|
self.assertNotContains(response=response, text='other list item 2')
|
||||||
|
|
||||||
class ListAndItemModelsTest(TestCase):
|
class ListAndItemModelsTest(TestCase):
|
||||||
|
|
||||||
|
@ -14,4 +14,4 @@ def view_list(request, list_id):
|
|||||||
def new_list(request):
|
def new_list(request):
|
||||||
list_ = List.objects.create()
|
list_ = List.objects.create()
|
||||||
Item.objects.create(text=request.POST['item_text'], list=list_)
|
Item.objects.create(text=request.POST['item_text'], list=list_)
|
||||||
return redirect('/lists/the-only-list-in-the-world/')
|
return redirect(f'/lists/{list_.id}/')
|
Loading…
x
Reference in New Issue
Block a user