special-gallery: scope image prev/next/back to special galleries; add tests

This commit is contained in:
2026-03-27 21:04:18 -04:00
parent 0e48a5d9bd
commit 21a3ab40c5
6 changed files with 145 additions and 63 deletions

View File

@@ -91,6 +91,41 @@ class SpecialGalleriesTests(TestCase):
# Next should be c.jpg (since favorites are a.jpg and c.jpg sorted)
self.assertIn("c.jpg", ctx.get("next"))
def test_favorites_image_view_prev_next_urls_and_back_link(self):
# Image view under favorites should produce prev/next URLs scoped to favorites
resp = self.client.get("/gallery/favorites/a.jpg/")
self.assertEqual(resp.status_code, 200)
ctx = resp.context
self.assertTrue(ctx.get("is_special"))
crumbs = ctx.get("breadcrumbs")
# back link for template should point to the special root
self.assertTrue(crumbs[0]["path"].startswith("/gallery/favorites/"))
# prev_url should be None for first favorite; next_url should be inside favorites
self.assertIsNone(ctx.get("prev_url"))
next_url = ctx.get("next_url")
self.assertIsNotNone(next_url)
self.assertTrue(next_url.startswith("/gallery/favorites/"))
self.assertIn("c.jpg", next_url)
def test_most_visited_image_view_prev_next_urls(self):
# most-visited image view should scope prev/next URLs to the most-visited gallery
resp = self.client.get("/gallery/most-visited/b.jpg/")
self.assertEqual(resp.status_code, 200)
ctx = resp.context
self.assertTrue(ctx.get("is_special"))
crumbs = ctx.get("breadcrumbs")
self.assertTrue(crumbs[0]["path"].startswith("/gallery/most-visited/"))
# b.jpg is the top most-visited image in fixtures => prev_url None, next_url points to a.jpg
self.assertIsNone(ctx.get("prev_url"))
next_url = ctx.get("next_url")
self.assertIsNotNone(next_url)
self.assertTrue(next_url.startswith("/gallery/most-visited/"))
self.assertIn("a.jpg", next_url)
def test_most_visited_and_recent_directory_views(self):
# most-visited should list images ordered by visits desc
resp = self.client.get("/gallery/most-visited/")