Example #1
0
 def test_block_alt_text_on_both(self):
     image_with_alt_text = baker.make(CFGOVImage, alt='Alt text on upload')
     block = ImageBasic()
     value = block.to_python({
         'upload': image_with_alt_text.pk,
         'alt': 'Alt text on block'
     })
     self.assertEqual(image_alt_value(value), 'Alt text on block')
Example #2
0
    def test_value_image_alt(self):
        image = make_image(alt_text='Image alt text')

        block = ImageBasic()
        value = block.to_python({'upload': image.pk})

        self.assertRegex(value.url, r'^.*/images/test.*\.original\.png$')
        self.assertEqual(value.alt_text, 'Image alt text')
Example #3
0
    def test_value_no_alt_returns_empty_string(self):
        image = make_image(alt_text='')

        block = ImageBasic()
        value = block.to_python({'upload': image.pk})

        self.assertRegex(value.url, r'^.*/images/test.*\.original\.png$')
        self.assertEqual(value.alt_text, '')
 def test_block_alt_text_on_both(self):
     image_with_alt_text = mommy.make(CFGOVImage, alt='Alt text on upload')
     block = ImageBasic()
     value = block.to_python({'upload': image_with_alt_text.pk,
                              'alt': 'Alt text on block'})
     self.assertEqual(image_alt_value(value), 'Alt text on block')
 def test_block_no_alt_text_set(self):
     image_no_alt_text = mommy.make(CFGOVImage, alt='')
     block = ImageBasic()
     value = block.to_python({'upload': image_no_alt_text.pk, 'alt': ''})
     self.assertEqual(image_alt_value(value), '')
 def test_block_no_image_in_block(self):
     block = ImageBasic()
     value = block.to_python({})
     self.assertEqual(image_alt_value(value), '')
Example #7
0
 def test_block_no_alt_text_set(self):
     image_no_alt_text = baker.make(CFGOVImage, alt='')
     block = ImageBasic()
     value = block.to_python({'upload': image_no_alt_text.pk, 'alt': ''})
     self.assertEqual(image_alt_value(value), '')
Example #8
0
 def test_block_no_image_in_block(self):
     block = ImageBasic()
     value = block.to_python({})
     self.assertEqual(image_alt_value(value), '')
Example #9
0
 def test_value_no_upload_undefined_url_and_alt_text(self):
     block = ImageBasic()
     value = block.to_python({})
     self.assertIsNone(value.url)
     self.assertIsNone(value.alt_text)