new form model in apps.dashboard.forms to handle existing item-lists; new test model in .tests.test_forms to accommodate; also new method in .test_views, but skipped for now

This commit is contained in:
Disco DeDisco
2026-01-23 22:23:40 -05:00
parent 6804d3aaae
commit 004241d52d
3 changed files with 54 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
from django.test import TestCase
from django.utils import html
from unittest import skip
from ..forms import EMPTY_ITEM_ERROR
from ..models import Item, List
import lxml.html
@@ -117,3 +118,18 @@ class DashViewTest(TestCase):
def test_for_invalid_input_shows_error_on_page(self):
response = self.post_invalid_input()
self.assertContains(response, html.escape(EMPTY_ITEM_ERROR))
@skip
def test_duplicate_item_validation_errors_end_up_on_lists_page(self):
list1 = List.objects.create()
Item.objects.create(list=list1, text="lorem ipsum")
response = self.client.post(
f"/apps/dashboard/{list1.id}/",
data={"text": "lorem ipsum"},
)
expected_error = html.escape("You've already logged this to your list")
self.assertContains(response, expected_error)
self.assertTemplateUsed(response, "apps/dashboard/list.html")
self.assertEqual(Item.objects.all().count(), 1)