defined Meta ordering of the Item() model in apps.dashboard.models; Item() also now returns a __str__ result; in .forms, defined a specific use-case of is_valid() method; a pair of new UTs in .tests.test_models help confirm str representation and list order of items; .test_forms now ensures the .is-invalid bootstrap class is tested as a css class attr; migrations run; full UT & FT suite back to passing state (tho a refactor of flimsy form customizations is desperately needed)
This commit is contained in:
@@ -41,7 +41,21 @@ 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()
|
||||
self.assertEqual(mylist.get_absolute_url(), f"/apps/dashboard/{mylist.id}/")
|
||||
|
||||
def test_list_items_order(self):
|
||||
list1 = List.objects.create()
|
||||
item1 = Item.objects.create(list=list1, text="i1")
|
||||
item2 = Item.objects.create(list=list1, text="item 2")
|
||||
item3 = Item.objects.create(list=list1, text="3")
|
||||
self.assertEqual(
|
||||
list(list1.item_set.all()),
|
||||
[item1, item2, item3],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user