def test_CAN_save_name_item_do_different_lists(self): list1 = List.objects.create() list2 = List.objects.create() Item.objects.create(list=list1, text='bla') item = Item(list=list2, text='bla') item.full_clean() # should not raise
def test_cannot_save_empty_list_items(self): list_ = List.objects.create() item = Item(list=list_, text='') with self.assertRaises(ValidationError): item.save() item.full_clean()
def test_duplicates_items_are_invalid(self): list_ = List.objects.create() Item.objects.create(list=list_, text='bla') with self.assertRaises(ValidationError): item = Item(list=list_, text='bla') item.full_clean()
def test_item_is_related_to_list(self): list_ = List.objects.create() item = Item() item.list = list_ item.save() self.assertIn(item, list_.item_set.all())