Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Jul 27, 2024
1 parent da9382a commit d455b42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion easy_thumbnails/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

STORAGES = {
"easy_thumbnails": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
"BACKEND": "easy_thumbnails.tests.utils.TemporaryStorage",
},
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
Expand Down
15 changes: 15 additions & 0 deletions easy_thumbnails/tests/test_thumbnail_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ def test_cleanup_last_n_days(self):
# Verify the source reference has been deleted
with self.assertRaises(Source.DoesNotExist):
Source.objects.get(id=self.source.id)

def test_source_storage_hash_not_found(self):
self.assertTrue(os.path.exists(self.source_image_path))
self.assertTrue(os.path.exists(self.thumbnail_path))

# Change the source's storage_hash to simulate an unknown storage hash
self.source.storage_hash = "unknown_storage_hash"
self.source.save()

# Run the thumbnail cleanup command
call_command("thumbnail_cleanup", verbosity=2)

# Verify the thumbnail and source still exist
self.assertTrue(os.path.exists(self.thumbnail_path))
self.assertIsNotNone(Source.objects.get(id=self.source.id))

0 comments on commit d455b42

Please sign in to comment.