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')
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')
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')
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')
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)
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)
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')
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')
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)