Skip to content

Commit

Permalink
Add factory tests
Browse files Browse the repository at this point in the history
The RootSectionFactory was generating an invalid model.
  • Loading branch information
nikolas committed Nov 18, 2016
1 parent e32e9bd commit 9e39a6d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pagetree/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class Meta:

hierarchy = factory.SubFactory(HierarchyFactory)
label = "Root"
slug = ""
path = "path"
slug = "slug"
depth = 0


Expand Down
27 changes: 26 additions & 1 deletion pagetree/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,35 @@
from pagetree.models import Hierarchy, PageBlock, UserPageVisit
from pagetree.test_models import TestBlock
from pagetree.tests.factories import (
RootSectionFactory, TestBlockFactory, UserFactory, UserPageVisitFactory
RootSectionFactory, TestBlockFactory, UserFactory, UserPageVisitFactory,
HierarchyFactory
)


class UserTest(TestCase):
def setUp(self):
self.u = UserFactory()

def test_is_valid_from_factory(self):
self.u.full_clean()


class HierarchyTest(TestCase):
def setUp(self):
self.h = HierarchyFactory()

def test_is_valid_from_factory(self):
self.h.full_clean()


class RootSectionTest(TestCase):
def setUp(self):
self.s = RootSectionFactory()

def test_is_valid_from_factory(self):
self.s.full_clean()


class EmptyHierarchyTest(TestCase):
""" a hierarchy with no sections in it
(one Root gets created by default) """
Expand Down

0 comments on commit 9e39a6d

Please sign in to comment.