Beispiel #1
0
    def test_category_three_deep_as_grandchild(self):
        child_category = Category(name='Child category')
        child_category.parent = self.category
        child_category.save()

        grand_child_category = Category(name='Grandchild category')
        grand_child_category.parent = child_category

        self.assertRaises(ValidationError, grand_child_category.save)
Beispiel #2
0
    def test_category_two_deep(self):
        child_category = Category(name='Child category')
        child_category.parent = self.category
        child_category.save()

        self.category.refresh_from_db()
        self.assertEqual(1, self.category.children.count())