refactor: split directory and image rendering into viewer.directory, viewer.image; add viewer.common for shared helpers

This commit is contained in:
2026-03-23 23:48:23 -04:00
parent caf8130c93
commit 3e209519e5
5 changed files with 595 additions and 522 deletions

View File

@@ -12,7 +12,9 @@ from django.test import Client, RequestFactory, TestCase, override_settings
from django.contrib.auth.models import User
# Project imports.
from viewer.views import SORT_LABELS, do_recursive_search, gallery_view
from viewer.common import SORT_LABELS
from viewer.directory import do_recursive_search
from viewer.views import gallery_view
class GalleryBaseTests(TestCase):
@@ -280,7 +282,7 @@ class GalleryViewTests(GalleryBaseTests):
self.assertNotIn("symlink_sub", names)
def test_thumbnail_failure_does_not_break_render(self):
with patch("viewer.views.make_thumbnail", side_effect=Exception("fail")):
with patch("viewer.common.make_thumbnail", side_effect=Exception("fail")):
response = self.client.get("/gallery/")
self.assertEqual(response.status_code, 200)
@@ -383,7 +385,7 @@ class GalleryViewTests(GalleryBaseTests):
def fake_creation(path_obj):
return creation_values.get(path_obj.name, 0)
with patch("viewer.views.get_creation_timestamp", side_effect=fake_creation):
with patch("viewer.common.get_creation_timestamp", side_effect=fake_creation):
old = self.client.get("/gallery/?sort=old")
new = self.client.get("/gallery/?sort=new")