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:
Disco DeDisco
2026-01-19 16:35:00 -05:00
parent d05d296f65
commit 8d23d9f2c2
6 changed files with 56 additions and 20 deletions

View File

@@ -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()