not getting the same precise error message, but perhaps the intent is the same?; anyway, updated views & some FTs, base.html for more dynamic error handling (tho incomplete)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db.utils import IntegrityError
|
||||
from django.test import TestCase
|
||||
from ..models import Item, List
|
||||
|
||||
@@ -28,4 +30,15 @@ class ListAndItemModelsTest(TestCase):
|
||||
self.assertEqual(first_saved_item.list, mylist)
|
||||
self.assertEqual(second_saved_item.text, "A sequel somehow better than the first")
|
||||
self.assertEqual(second_saved_item.list, mylist)
|
||||
|
||||
|
||||
def test_cannot_save_null_list_items(self):
|
||||
mylist = List.objects.create()
|
||||
item = Item(list=mylist, text=None)
|
||||
with self.assertRaises(IntegrityError):
|
||||
item.save()
|
||||
|
||||
def test_cannot_save_empty_list_items(self):
|
||||
mylist = List.objects.create()
|
||||
item = Item(list=mylist, text="")
|
||||
with self.assertRaises(ValidationError):
|
||||
item.full_clean()
|
||||
|
||||
Reference in New Issue
Block a user