Ejemplo n.º 1
0
    def test_is_child(self):
        category = factories.CategoryFactory(name='Child category', parent=None)
        self.assertFalse(category.is_child())

        category.parent = self.category
        category.save()

        self.assertTrue(category.is_child())
Ejemplo n.º 2
0
    def test_is_parent(self):
        self.assertFalse(self.category.is_parent())

        child_category = factories.CategoryFactory(name='Child category')
        child_category.parent = self.category
        child_category.save()

        self.category.refresh_from_db()
        self.assertTrue(self.category.is_parent())