reorganized and reclassified old 'unit tests' for ea. app into dirs for UTs & ITs; abandoning effort to refactor any test_views into UTs; all tests passing
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-02-18 19:07:02 -05:00
parent c41624152a
commit a06fce26ef
13 changed files with 57 additions and 28 deletions

View File

@@ -1,18 +1,15 @@
from django.test import TestCase
from ..forms import (
from apps.dashboard.forms import (
DUPLICATE_ITEM_ERROR,
EMPTY_ITEM_ERROR,
ExistingListItemForm,
ItemForm,
)
from ..models import Item, List
from apps.dashboard.models import Item, List
class ItemFormTest(TestCase):
def test_form_validation_for_blank_items(self):
form = ItemForm(data={"text": ""})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors["text"], [EMPTY_ITEM_ERROR])
def test_form_save_handles_saving_to_a_list(self):
mylist = List.objects.create()
form = ItemForm(data={"text": "do re mi"})

View File

@@ -1,14 +1,12 @@
from django.core.exceptions import ValidationError
from django.db.utils import IntegrityError
from django.test import TestCase
from ..models import Item, List
from apps.dashboard.models import Item, List
from apps.lyric.models import User
class ItemModelTest(TestCase):
def test_default_text(self):
item = Item()
self.assertEqual(item.text, "")
def test_item_is_related_to_list(self):
mylist = List.objects.create()
item = Item()
@@ -42,10 +40,6 @@ class ItemModelTest(TestCase):
item = Item(list=list2, text="nojk")
item.full_clean() # should not raise
def test_string_representation(self):
item = Item(text="sample text")
self.assertEqual(str(item), "sample text")
class ListModelTest(TestCase):
def test_get_absolute_url(self):
mylist = List.objects.create()

View File

@@ -1,13 +1,14 @@
import lxml.html
from unittest import skip
from django.test import TestCase
from django.utils import html
from ..forms import (
from apps.dashboard.forms import (
DUPLICATE_ITEM_ERROR,
EMPTY_ITEM_ERROR,
)
from ..models import Item, List
from apps.dashboard.models import Item, List
from apps.lyric.models import User

View File

@@ -0,0 +1,13 @@
from django.test import SimpleTestCase
from apps.dashboard.forms import (
EMPTY_ITEM_ERROR,
ItemForm,
)
class SimpleItemFormTest(SimpleTestCase):
def test_form_validation_for_blank_items(self):
form = ItemForm(data={"text": ""})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors["text"], [EMPTY_ITEM_ERROR])

View File

@@ -0,0 +1,13 @@
from django.test import SimpleTestCase
from apps.dashboard.models import Item
class SimpleItemModelTest(SimpleTestCase):
def test_default_text(self):
item = Item()
self.assertEqual(item.text, "")
def test_string_representation(self):
item = Item(text="sample text")
self.assertEqual(str(item), "sample text")