Exemple #1
0
class SectionTest(TestCase):
    def setUp(self):
        self.user = UserFactory()
        self.section = RootSectionFactory()

    def test_add_pageblock_from_dict(self):
        self.section.add_pageblock_from_dict({
            'block_type': 'Test Block',
            'body': 'test body',
        })
        block = self.section.pageblock_set.first()
        assert(block is not None)
        self.assertEqual(block.block().body, 'test body')
        self.assertEqual(
            self.section.pageblock_set.first(), block,
            'The PageBlock has been added to the Section')

    def test_empty_section_is_unlocked(self):
        self.assertTrue(self.section.unlocked(self.user))

    def test_section_with_test_block_is_unlocked(self):
        self.section.add_pageblock_from_dict({'block_type': 'Test Block'})
        self.assertEqual(self.section.pageblock_set.count(), 1)

        # TestBlock doesn't have an "unlocked" method defined, so this
        # tests that Section.unlocked() handles that case.
        self.assertTrue(self.section.unlocked(self.user))
Exemple #2
0
class SectionTest(TestCase):
    def setUp(self):
        self.user = UserFactory()
        self.section = RootSectionFactory()

    def test_add_pageblock_from_dict(self):
        self.section.add_pageblock_from_dict({
            'block_type': 'Test Block',
            'body': 'test body',
        })
        block = self.section.pageblock_set.first()
        assert (block is not None)
        self.assertEqual(block.block().body, 'test body')
        self.assertEqual(self.section.pageblock_set.first(), block,
                         'The PageBlock has been added to the Section')

    def test_empty_section_is_unlocked(self):
        self.assertTrue(self.section.unlocked(self.user))

    def test_section_with_test_block_is_unlocked(self):
        self.section.add_pageblock_from_dict({'block_type': 'Test Block'})
        self.assertEqual(self.section.pageblock_set.count(), 1)

        # TestBlock doesn't have an "unlocked" method defined, so this
        # tests that Section.unlocked() handles that case.
        self.assertTrue(self.section.unlocked(self.user))
Exemple #3
0
 def setUp(self):
     self.user = UserFactory()
     self.section = RootSectionFactory()
Exemple #4
0
 def setUp(self):
     self.s = RootSectionFactory()
Exemple #5
0
class RootSectionTest(TestCase):
    def setUp(self):
        self.s = RootSectionFactory()

    def test_is_valid_from_factory(self):
        self.s.full_clean()
Exemple #6
0
 def setUp(self):
     self.user = UserFactory()
     self.section = RootSectionFactory()
Exemple #7
0
 def setUp(self):
     self.s = RootSectionFactory()
Exemple #8
0
class RootSectionTest(TestCase):
    def setUp(self):
        self.s = RootSectionFactory()

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