コード例 #1
0
ファイル: tests.py プロジェクト: LubomirR/Shakal-NG
	def create_image_instance(self, **kwargs):
		image = create_image(**kwargs)

		instance = ImageFieldModel()
		instance.image = SimpleUploadedFile(image.name, image.read())
		instance.save()
		return instance
コード例 #2
0
ファイル: tests.py プロジェクト: tanveerahmad1517/Shakal-NG
    def create_image_instance(self, **kwargs):
        image = create_image(**kwargs)

        instance = ImageFieldModel()
        instance.image = SimpleUploadedFile(image.name, image.read())
        instance.save()
        return instance
コード例 #3
0
ファイル: tests.py プロジェクト: LubomirR/Shakal-NG
	def test_reupload(self):
		instance = self.create_image_instance(size=(128, 128))
		path1 = instance.image.path
		path1_thumbnail = instance.image_thumbnail.path #pylint: disable=no-member

		instance = ImageFieldModel.objects.get(pk=instance.pk)
		image = create_image(size=(128, 128), filetype='jpeg', basename='new')
		instance.image = SimpleUploadedFile(image.name, image.read())
		instance.save()

		path2 = instance.image.path
		path2_thumbnail = instance.image_thumbnail.path #pylint: disable=no-member

		self.assertNotEquals(path1, path2)
		self.assertNotEquals(path1_thumbnail, path2_thumbnail)
		self.assertFalse(os.path.exists(path1))
		self.assertFalse(os.path.exists(path1_thumbnail))
		self.assertTrue(os.path.exists(path2))
		self.assertTrue(os.path.exists(path2_thumbnail))

		self.destroy_image_instance(instance)
コード例 #4
0
ファイル: tests.py プロジェクト: tanveerahmad1517/Shakal-NG
    def test_reupload(self):
        instance = self.create_image_instance(size=(128, 128))
        path1 = instance.image.path
        path1_thumbnail = generate_thumbnail(instance.image,
                                             size=(32, 32)).path

        instance = ImageFieldModel.objects.get(pk=instance.pk)
        image = create_image(size=(128, 128), filetype='jpeg', basename='new')
        instance.image = SimpleUploadedFile(image.name, image.read())
        instance.save()

        path2 = instance.image.path
        path2_thumbnail = generate_thumbnail(instance.image,
                                             size=(32, 32)).path

        self.assertNotEqual(path1, path2)
        self.assertNotEqual(path1_thumbnail, path2_thumbnail)
        self.assertFalse(os.path.exists(path1))
        self.assertFalse(os.path.exists(path1_thumbnail))
        self.assertTrue(os.path.exists(path2))
        self.assertTrue(os.path.exists(path2_thumbnail))

        self.destroy_image_instance(instance)