-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fill_gallery generates thumbnail synchronously
- Loading branch information
Showing
1 changed file
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) |