Пример #1
0
 def test_category2(self):
     """Slugs are unique.
     """
     root_category = Category(
         name='root', slug='root')
     root_category.save()
     second_root_category = Category(
         name='root', slug='root')
     self.assertRaises(IntegrityError, second_root_category.save)
Пример #2
0
 def test_no_infinite_recursion_in_unicode(self):
     """Pointing a category's parent field at itself would give an infinite
     recursion error in __unicode__().
     """
     category = Category(
         name='root', slug='root')
     category.save()
     category.parent = category
     self.assertRaises(ValidationError, category.save)
Пример #3
0
 def test_category(self):
     """Adding parents and childs.
     """
     root_category = Category(
         name='root', slug='root')
     root_category.save()
     child_category = Category(
         name='child',
         slug='child',
         parent=root_category)
     child_category.save()
     children = root_category.get_children()
     self.assertEquals(len(children), 1)
     self.assertEquals(str(children[0]), str(child_category))