Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 3
0
 def setUp(self):
     self.user = UserFactory()
     self.section = RootSectionFactory()
Exemplo n.º 4
0
 def setUp(self):
     self.s = RootSectionFactory()
Exemplo n.º 5
0
class RootSectionTest(TestCase):
    def setUp(self):
        self.s = RootSectionFactory()

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

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