|
9 | 9 | from PIL import Image |
10 | 10 |
|
11 | 11 | from . import models |
12 | | -from .models import (AdminDeleteModel, CustomRenderVariationsModel, ResizeCropModel, |
13 | | - ResizeModel, SimpleModel, ThumbnailModel, |
| 12 | +from .models import (AdminDeleteModel, AdminUpdateModel, CustomRenderVariationsModel, |
| 13 | + ResizeCropModel, ResizeModel, SimpleModel, ThumbnailModel, |
14 | 14 | ThumbnailWithoutDirectoryModel, UtilVariationsModel,) |
15 | 15 |
|
16 | 16 | IMG_DIR = os.path.join(settings.MEDIA_ROOT, 'img') |
@@ -198,13 +198,28 @@ def test_pre_save_delete_callback_clear(self, admin_client): |
198 | 198 | assert not os.path.exists(path) |
199 | 199 |
|
200 | 200 | def test_pre_save_delete_callback_new(self, admin_client): |
201 | | - AdminDeleteModel.objects.create( |
| 201 | + obj = AdminDeleteModel.objects.create( |
202 | 202 | image=self.fixtures['100.gif'] |
203 | 203 | ) |
| 204 | + path = obj.image.path |
| 205 | + assert os.path.exists(path) |
204 | 206 | admin_client.post('/admin/tests/admindeletemodel/1/change/', { |
205 | 207 | 'image': self.fixtures['600x400.jpg'], |
206 | 208 | }) |
207 | | - assert not os.path.exists(os.path.join(IMG_DIR, 'image.gif')) |
| 209 | + assert not os.path.exists(path) |
| 210 | + assert os.path.exists(os.path.join(IMG_DIR, '600x400.jpg')) |
| 211 | + |
| 212 | + def test_pre_save_delete_callback_update(self, admin_client): |
| 213 | + obj = AdminUpdateModel.objects.create( |
| 214 | + image=self.fixtures['100.gif'] |
| 215 | + ) |
| 216 | + path = obj.image.path |
| 217 | + assert os.path.exists(path) |
| 218 | + admin_client.post('/admin/tests/adminupdatemodel/1/change/', { |
| 219 | + 'image': self.fixtures['600x400.jpg'], |
| 220 | + }) |
| 221 | + assert not os.path.exists(path) |
| 222 | + assert os.path.exists(os.path.join(IMG_DIR, '600x400.jpg')) |
208 | 223 |
|
209 | 224 | def test_render_variations_callback(self, db): |
210 | 225 | obj = UtilVariationsModel.objects.create(image=self.fixtures['100.gif']) |
|
0 commit comments