Ejemplo n.º 1
0
    def test_heading_only_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({'heading': {'text': 'Heading'}})

        try:
            block.clean(value)
        except ValidationError:
            self.fail('heading alone should not fail validation')
Ejemplo n.º 2
0
    def test_no_heading_or_intro_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({})

        try:
            block.clean(value)
        except ValidationError:
            self.fail('no heading and no intro should not fail validation')
Ejemplo n.º 3
0
    def test_no_heading_or_intro_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({})

        try:
            block.clean(value)
        except ValidationError:
            self.fail('no heading and no intro should not fail validation')
Ejemplo n.º 4
0
    def test_heading_only_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({
            'heading': {
                'text': 'Heading'
            }
        })

        try:
            block.clean(value)
        except ValidationError:
            self.fail('heading alone should not fail validation')
Ejemplo n.º 5
0
    def test_heading_and_intro_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({
            'heading': {
                'text': 'Heading'
            },
            'intro': '<p>Rich txt</p>'
        })

        try:
            block.clean(value)
        except ValidationError:
            self.fail('heading with intro should not fail validation')
Ejemplo n.º 6
0
    def test_heading_and_intro_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({
            'heading': {
                'text': 'Heading'
            },
            'intro': '<p>Rich txt</p>'
        })

        try:
            block.clean(value)
        except ValidationError:
            self.fail('heading with intro should not fail validation')
Ejemplo n.º 7
0
    def test_2575_with_no_images_fails_validation(self):
        block = InfoUnitGroup()
        value = block.to_python({
            'format':
            '25-75',
            'info_units': [{
                'image': {},
                'body': '<p>Info unit with no image</p>',
                'links': [],  # must remove default empty link
            }]
        })

        with self.assertRaises(ValidationError):
            block.clean(value)
Ejemplo n.º 8
0
    def test_2575_with_no_images_fails_validation(self):
        block = InfoUnitGroup()
        value = block.to_python({
            'format': '25-75',
            'info_units': [
                {
                    'image': {},
                    'body': '<p>Info unit with no image</p>',
                    'links': [],  # must remove default empty link
                }
            ]
        })

        with self.assertRaises(ValidationError):
            block.clean(value)
Ejemplo n.º 9
0
    def test_2575_with_image_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({
            'format':
            '25-75',
            'info_units': [{
                'image': {
                    'upload': self.image.pk
                },
                'links': [],  # must remove default empty link
            }]
        })

        try:
            block.clean(value)
        except ValidationError:
            self.fail('25-75 group with info unit that has an image validates')
Ejemplo n.º 10
0
    def test_2575_with_image_ok(self):
        block = InfoUnitGroup()
        value = block.to_python({
            'format': '25-75',
            'info_units': [
                {
                    'image': {
                        'upload': self.image.pk
                    },
                    'links': [],  # must remove default empty link
                }
            ]
        })

        try:
            block.clean(value)
        except ValidationError:
            self.fail('25-75 group with info unit that has an image validates')
Ejemplo n.º 11
0
    def test_intro_only_fails_validation(self):
        block = InfoUnitGroup()
        value = block.to_python({'intro': '<p>Only an intro</p>'})

        with self.assertRaises(ValidationError):
            block.clean(value)
Ejemplo n.º 12
0
    def test_intro_only_fails_validation(self):
        block = InfoUnitGroup()
        value = block.to_python({'intro': '<p>Only an intro</p>'})

        with self.assertRaises(ValidationError):
            block.clean(value)