Пример #1
0
    def __init__(self):
        hierarchy = HierarchyFactory(name='main', base_url='/pages/')
        root = hierarchy.get_root()
        root.add_child_section_from_dict({
            'label': 'Welcome to the Intro Page',
            'slug': 'intro',
            'children': [
                {
                    'label': 'Step 1',
                    'slug': 'step-1',
                    'pageblocks': [{
                        'block_type': 'Text Block'
                    }]
                },
                {
                    'label': 'Step 2',
                    'slug': 'step-2',
                    'pageblocks': [{
                        'block_type': 'My Block Name'
                    }]
                },
            ]
        })

        self.root = root
Пример #2
0
    def __init__(self):
        hierarchy = HierarchyFactory(name='main', base_url='/pages/')
        root = hierarchy.get_root()
        root.add_child_section_from_dict({
            'label':
            'Welcome to the Intro Page',
            'slug':
            'intro',
            'children': [
                {
                    'label': 'Step 1',
                    'slug': 'step-1',
                    'pageblocks': [{
                        'block_type': 'Text Block'
                    }]
                },
                {
                    'label': 'Step 2',
                    'slug': 'step-2',
                    'pageblocks': [{
                        'block_type': 'My Block Name'
                    }]
                },
            ]
        })

        self.root = root
Пример #3
0
    def setUp(self):
        self.user = User.objects.create(username="******")

        hierarchy = HierarchyFactory()

        hierarchy.get_root().add_child_section_from_dict({
            'label':
            'Page One',
            'slug':
            'page-one',
            'pageblocks': [
                {
                    'label': 'pretest page one',
                    'css_extra': 'foo',
                    'block_type': 'Quiz',
                    'rhetorical': False,
                    'description': 'the first quiz',
                    'questions': []
                },
            ],
            'children': [],
        })
        hierarchy.get_root().add_child_section_from_dict({
            'label':
            'Page Two',
            'slug':
            'page-two',
            'pageblocks': [
                {
                    'label': 'pretest page two',
                    'css_extra': 'foo',
                    'block_type': 'Quiz',
                    'rhetorical': False,
                    'description': 'the second quiz',
                    'questions': []
                },
            ],
            'children': [],
        })
        hierarchy.get_root().add_child_section_from_dict({
            'label':
            'Page Three',
            'slug':
            'page-three',
            'pageblocks': [
                {
                    'label': 'pretest page three',
                    'css_extra': 'bar',
                    'block_type': 'Quiz',
                    'rhetorical': False,
                    'description': 'the third quiz',
                    'questions': []
                },
            ],
            'children': [],
        })
Пример #4
0
 def test_clean_no_base_url(self):
     h = HierarchyFactory()
     f = CloneHierarchyForm({
         'name': 'new name',
         'base_url': '',
     }, instance=h)
     self.assertTrue(f.is_valid())
     new_hier = f.save()
     self.assertEqual(new_hier.name, 'new name')
     self.assertEqual(new_hier.base_url, 'new-name')
Пример #5
0
 def test_clean_prevents_duplicate_base_url(self):
     h = HierarchyFactory()
     f = CloneHierarchyForm({
         'name': 'new name',
         'base_url': h.base_url,
     }, instance=h)
     self.assertFalse(f.is_valid())
     self.assertEqual(f.errors, {
         '__all__': [
             u"There's already a hierarchy with the base_url: /pages/"]
     })
Пример #6
0
    def setUp(self):
        self.user = User.objects.create(username="******")

        hierarchy = HierarchyFactory()

        hierarchy.get_root().add_child_section_from_dict({
            'label': 'Page One',
            'slug': 'page-one',
            'pageblocks': [{
                'label': 'pretest page one',
                'css_extra': 'foo',
                'block_type': 'Quiz',
                'rhetorical': False,
                'description': 'the first quiz',
                'questions': []},
            ],
            'children': [],
        })
        hierarchy.get_root().add_child_section_from_dict({
            'label': 'Page Two',
            'slug': 'page-two',
            'pageblocks': [{
                'label': 'pretest page two',
                'css_extra': 'foo',
                'block_type': 'Quiz',
                'rhetorical': False,
                'description': 'the second quiz',
                'questions': []},
            ],
            'children': [],
        })
        hierarchy.get_root().add_child_section_from_dict({
            'label': 'Page Three',
            'slug': 'page-three',
            'pageblocks': [{
                'label': 'pretest page three',
                'css_extra': 'bar',
                'block_type': 'Quiz',
                'rhetorical': False,
                'description': 'the third quiz',
                'questions': []},
            ],
            'children': [],
        })
Пример #7
0
 def test_init(self):
     h = HierarchyFactory()
     CloneHierarchyForm(instance=h)
Пример #8
0
 def setUp(self):
     self.h = HierarchyFactory()
Пример #9
0
class HierarchyTest(TestCase):
    def setUp(self):
        self.h = HierarchyFactory()

    def test_is_valid_from_factory(self):
        self.h.full_clean()
Пример #10
0
 def setUp(self):
     self.h = HierarchyFactory()
Пример #11
0
class HierarchyTest(TestCase):
    def setUp(self):
        self.h = HierarchyFactory()

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