From c6507b79f824796639b7db657d63a1415150a1ac Mon Sep 17 00:00:00 2001 From: Olexandr Date: Thu, 20 Aug 2015 14:21:18 +0300 Subject: [PATCH] fill_gallery generates thumbnail synchronously --- project/gallery.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/project/gallery.py b/project/gallery.py index 915ebd0..6214715 100644 --- a/project/gallery.py +++ b/project/gallery.py @@ -1,12 +1,18 @@ from werkzeug.datastructures import FileStorage from project.models import UploadedImage +from unittest.mock import patch +from project.tasks.uploads import celery_make_thumbnail as make_thumbnail def load_images(count=100): for _ in range(count): with open('testdata/images/face-2.jpg', 'rb') as fp: file = FileStorage(fp) - UploadedImage.bl.save_image( - image=file, - img_category=UploadedImage.IMG_CATEGORY.gallery, - ) + with patch( + target='project.tasks.uploads.celery_make_thumbnail.delay', + new=make_thumbnail, + ): + UploadedImage.bl.save_image( + image=file, + img_category=UploadedImage.IMG_CATEGORY.gallery, + )