def test_if_form_has_image_field_instance_of_image_field_file(self):
        object = ModelWithImage(image='my_image.jpg')
        object.save()

        object = ModelWithImage.unmoderated_objects.get(id=1)
        form = self.ModeratedObjectForm(instance=object)
        self.assertTrue(isinstance(form.initial['image'], ImageFieldFile),
                        'image in form.initial is instance of ImageField File')
Esempio n. 2
0
    def test_if_form_has_image_field_instance_of_image_field_file(self):
        object = ModelWithImage(image='my_image.jpg')
        object.save()

        object = ModelWithImage.unmoderated_objects.get(id=1)
        form = self.ModeratedObjectForm(instance=object)
        self.assertTrue(isinstance(form.initial['image'], ImageFieldFile),
                        'image in form.initial is instance of ImageField File')
Esempio n. 3
0
 def setUp(self):
     image1 = ModelWithImage(image='my_image.jpg')
     image1.save()
     image2 = ModelWithImage(image='my_image2.jpg')
     image2.save()
     self.left_image = image1.image
     self.right_image = image2.image
     self.change = ImageChange(verbose_name='image',
                               field=fields.files.ImageField,
                               change=(self.left_image, self.right_image))
Esempio n. 4
0
    def test_get_changes_between_models_image(self):
        '''Verify proper diff for ImageField fields'''

        image1 = ModelWithImage(image='tmp/test1.jpg')
        image1.save()
        image2 = ModelWithImage(image='tmp/test2.jpg')
        image2.save()

        changes = get_changes_between_models(image1, image2)
        self.assertEqual(
            norm_whitespace(changes['modelwithimage__image'].diff),
            norm_whitespace(u'<img src="/media/tmp/test1.jpg"> '
                            u'<img style="margin-left: 10px;" '
                            u'src="/media/tmp/test2.jpg">'))
Esempio n. 5
0
    def test_get_changes_between_models_image(self):
        '''Verify proper diff for ImageField fields'''

        image1 = ModelWithImage(image='tmp/test1.jpg')
        image1.save()
        image2 = ModelWithImage(image='tmp/test2.jpg')
        image2.save()

        changes = get_changes_between_models(image1, image2)
        self.assertEqual(
            norm_whitespace(changes['modelwithimage__image'].diff),
            norm_whitespace('<div class="img-wrapper"> '
                            '<img src="/media/tmp/test1.jpg"> '
                            '<img src="/media/tmp/test2.jpg"> '
                            '</div>'))
 def setUp(self):
     image1 = ModelWithImage(image='my_image.jpg')
     image1.save()
     image2 = ModelWithImage(image='my_image2.jpg')
     image2.save()
     self.left_image = image1.image
     self.right_image = image2.image
     self.change = ImageChange(verbose_name='image',
                               field=fields.files.ImageField,
                               change=(self.left_image, self.right_image))
    def test_get_changes_between_models_image(self):
        '''Verify proper diff for ImageField fields'''

        image1 = ModelWithImage(image='tmp/test1.jpg')
        image1.save()
        image2 = ModelWithImage(image='tmp/test2.jpg')
        image2.save()

        changes = get_changes_between_models(image1, image2)
        self.assertEqual(
            norm_whitespace(changes['modelwithimage__image'].diff),
            norm_whitespace('<div class="img-wrapper"> '
                            '<img src="/media/tmp/test1.jpg"> '
                            '<img src="/media/tmp/test2.jpg"> '
                            '</div>'))