-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(document): adjust cloning for use with storage backends
NOTE: no automatic thumbnailgeneration
- Loading branch information
Showing
3 changed files
with
29 additions
and
21 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
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
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,28 +1,17 @@ | ||
import pytest | ||
|
||
from alexandria.core.factories import DocumentFactory, FileFactory | ||
from alexandria.core.models import File | ||
|
||
|
||
@pytest.mark.parametrize("admin_groups", [["foo"]]) | ||
def test_clone_document(admin_client, minio_mock): | ||
document = DocumentFactory() | ||
|
||
v1 = FileFactory(document=document, variant="original", name="v1") | ||
FileFactory(document=document, variant="thumbnail", original=v1) | ||
v2 = FileFactory(document=document, variant="original", name="v2") | ||
FileFactory( | ||
document=document, | ||
variant="thumbnail", | ||
original=v2, | ||
name="thumbnail_file", | ||
) | ||
|
||
clone = document.clone() | ||
def test_clone_document(admin_client, file_factory): | ||
v1_thumb = file_factory(variant=File.Variant.THUMBNAIL) | ||
v2_thumb = file_factory(variant=File.Variant.THUMBNAIL, document=v1_thumb.document) | ||
clone = v1_thumb.document.clone() | ||
|
||
# in the test, the thumbnail for the cloned file is not created | ||
# because the minio hook is not called | ||
assert File.objects.count() == 5 | ||
assert list(clone.files.values_list("name", flat=True)) == [ | ||
v2.name, | ||
v2_thumb.document.files.filter(variant=File.Variant.ORIGINAL).first().name, | ||
] |