|
@@ -36,10 +36,6 @@ class HomePageTest(TestCase):
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
self.assertEqual(response['location'], '/lists/the-only-list/')
|
|
|
|
|
|
- def test_only_saves_items_when_needed(self):
|
|
|
- self.client.get('/')
|
|
|
- self.assertEqual(Item.objects.count(), 0)
|
|
|
-
|
|
|
class ListViewTest(TestCase):
|
|
|
|
|
|
def test_uses_list_template(self):
|
|
@@ -73,3 +69,16 @@ class ItemModelTest(TestCase):
|
|
|
second_item = saved[1]
|
|
|
self.assertEqual(first_item.text, item1.text)
|
|
|
self.assertEqual(second_item.text, item2.text)
|
|
|
+
|
|
|
+class NewListTest(TestCase):
|
|
|
+
|
|
|
+ def test_can_save_a_POST_request(self):
|
|
|
+ self.client.post('/lists/new', data={'item_text': 'A new list item'})
|
|
|
+ self.assertEqual(Item.objects.count(), 1)
|
|
|
+ new_item = Item.objects.first()
|
|
|
+ self.assertEqual(new_item.text, 'A new list item')
|
|
|
+
|
|
|
+
|
|
|
+ def test_redirects_after_POST(self):
|
|
|
+ response = self.client.post('/lists/new', data={'item_text': 'A new list item'})
|
|
|
+ self.assertRedirects(response, '/lists/the-only-list/')
|