+2 new migrations in apps.dashboard; added new Item() model to dashboard.models; added ItemModelTest() to .tests; cleaned up deadspace in functional_tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.test import TestCase
|
||||
from .models import Item
|
||||
|
||||
class HomePageTest(TestCase):
|
||||
def test_uses_home_template(self):
|
||||
@@ -13,4 +14,22 @@ class HomePageTest(TestCase):
|
||||
def test_can_save_a_POST_request(self):
|
||||
response = self.client.post('/', data={'item-text': 'A new dashboard item'})
|
||||
self.assertContains(response, 'A new dashboard item')
|
||||
self.assertTemplateUsed(response, 'apps/dashboard/home.html')
|
||||
self.assertTemplateUsed(response, 'apps/dashboard/home.html')
|
||||
|
||||
class ItemModelTest(TestCase):
|
||||
def test_saving_and_retrieving_items(self):
|
||||
first_item = Item()
|
||||
first_item.text = "The first (ever) dashboard item"
|
||||
first_item.save()
|
||||
|
||||
second_item = Item()
|
||||
second_item.text = "A sequel somehow better than the first"
|
||||
second_item.save()
|
||||
|
||||
saved_items = Item.objects.all()
|
||||
self.assertEqual(saved_items.count(), 2)
|
||||
|
||||
first_saved_item = saved_items[0]
|
||||
second_saved_item = saved_items[1]
|
||||
self.assertEqual(first_saved_item.text, "The first (ever) dashboard item")
|
||||
self.assertEqual(second_saved_item.text, "A sequel somehow better than the first")
|
||||
Reference in New Issue
Block a user