Skip to content

Commit

Permalink
No need to test collection in document
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Jun 4, 2024
1 parent 900af5e commit 0586baf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
7 changes: 5 additions & 2 deletions apps/iiif/kollections/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def autocomplete_label(self):
return self.label

def __str__(self):
return self.label
return str(self.label)

def get_absolute_url(self):
"""Concatenated property for collection's URI"""
Expand Down Expand Up @@ -95,7 +95,8 @@ def __make_thumbnail(self):
size = (400, 500)
image = Image.open(self.thumbnail)

# We need to test that this if else works correctly so that new files can be uploaded and existing files are not renamed.
# We need to test that this if else works correctly so that new files can be
# uploaded and existing files are not renamed.
if 'thumbnails/' in self.thumbnail.name:
return True
else:
Expand Down Expand Up @@ -138,6 +139,7 @@ def __make_thumbnail(self):
temp_thumb.seek(0)

# set save=False, otherwise it will run in an infinite loop
# pylint: disable = no-member
self.thumbnail.save(thumb_filename, ContentFile(temp_thumb.read()), save=False)
temp_thumb.close()
return True
Expand Down Expand Up @@ -211,6 +213,7 @@ def __make_header(self):
temp_header.seek(0)

# set save=False, otherwise it will run in an infinite loop
# pylint: disable = no-member
self.header.save(thefilename, ContentFile(temp_header.read()), save=False)
temp_header.close()

Expand Down
21 changes: 11 additions & 10 deletions apps/iiif/manifests/tests/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ def test_get_queryset(self):
assert prefetched['collections'].count() == 1
assert prefetched['collections'].first().pk == collection.pk

def test_get_instances_from_related(self):
"""Should get manifests from related collections"""
manifest = ManifestFactory.create()
# connect a collection and manifest
collection = Collection(label="test collection")
collection.save()
manifest.collections.add(collection)
instances = self.doc.get_instances_from_related(related_instance=collection)
# should get the manifest related to this collection
self.assertQuerysetEqual(instances, [manifest])
# Removed test because we don't want to trigger a re-index when a collection is saved.
# def test_get_instances_from_related(self):
# """Should get manifests from related collections"""
# manifest = ManifestFactory.create()
# # connect a collection and manifest
# collection = Collection(label="test collection")
# collection.save()
# manifest.collections.add(collection)
# instances = self.doc.get_instances_from_related(related_instance=collection)
# # should get the manifest related to this collection
# self.assertQuerysetEqual(instances, [manifest])

0 comments on commit 0586baf

Please sign in to comment.