New English meme and flyer set, retire Dutch-text gallery images
This commit is contained in:
@@ -5,3 +5,22 @@ def test_galleries_have_images(anon):
|
||||
for path, minimum in (("/flyers", 4), ("/memes", 10)):
|
||||
html = anon.get(path).text
|
||||
assert html.count("data-lightbox") >= minimum, path
|
||||
|
||||
|
||||
def test_retired_dutch_images_are_not_listed(anon):
|
||||
from molodetz.gallery import RETIRED_GALLERY
|
||||
|
||||
for path in ("/flyers", "/memes"):
|
||||
items = anon.get(path, headers={"Accept": "application/json"}).json()["items"]
|
||||
names = {item["filename"] for item in items}
|
||||
assert not names & set(RETIRED_GALLERY), path
|
||||
assert all(item["caption"] for item in items), path
|
||||
|
||||
|
||||
def test_home_features_the_elite_twice_flyer(anon):
|
||||
html = anon.get("/").text
|
||||
assert "flyer-elite-twice.jpg" in html
|
||||
assert "Elite twice." in html
|
||||
counts = anon.get("/", headers={"Accept": "application/json"}).json()
|
||||
assert counts["flyer_count"] == 4
|
||||
assert counts["meme_count"] >= 18
|
||||
|
||||
@@ -43,7 +43,7 @@ def test_sitemap_lists_english_paths(anon):
|
||||
def test_gallery_captions_are_english(anon):
|
||||
flyers = anon.get("/flyers", headers={"Accept": "application/json"}).json()["items"]
|
||||
captions = {item["caption"] for item in flyers}
|
||||
assert "Thirty-one choices. You have zero." in captions
|
||||
assert "Taste does not autocomplete." in captions
|
||||
assert not any(" geen " in f" {caption.lower()} " or " een " in f" {caption.lower()} " for caption in captions)
|
||||
|
||||
|
||||
|
||||
+38
-1
@@ -1,6 +1,8 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
from molodetz import config
|
||||
from molodetz.gallery import GALLERY
|
||||
from PIL import Image
|
||||
|
||||
from molodetz.gallery import GALLERY, RETIRED_GALLERY
|
||||
|
||||
BANNED = ("selfie", "mirror", "devplace", "nigel", "nldr", "waifu", "zwem")
|
||||
|
||||
@@ -16,3 +18,38 @@ def test_gallery_files_exist_and_are_allowed():
|
||||
def test_both_kinds_present():
|
||||
kinds = {entry["kind"] if isinstance(entry, dict) else entry[1] for entry in GALLERY}
|
||||
assert {"flyer", "meme"} <= kinds
|
||||
|
||||
|
||||
def test_gallery_image_sizes_match_kind():
|
||||
for name, kind, _ in GALLERY:
|
||||
if not name.startswith(("flyer-elite", "flyer-taste", "flyer-demo", "flyer-hands", "meme-classic", "meme-vibe", "meme-elite")):
|
||||
continue
|
||||
with Image.open(config.MEDIA_SOURCE_DIR / name) as image:
|
||||
assert image.size == ((1080, 1350) if kind == "flyer" else (1080, 1080)), name
|
||||
|
||||
|
||||
def test_retired_files_stay_on_disk_but_leave_the_gallery():
|
||||
names = {entry[0] for entry in GALLERY}
|
||||
assert len(RETIRED_GALLERY) == 20
|
||||
for name in RETIRED_GALLERY:
|
||||
assert name not in names, name
|
||||
assert (config.MEDIA_SOURCE_DIR / name).is_file(), name
|
||||
|
||||
|
||||
def test_gallery_captions_are_clean_english():
|
||||
for name, _, caption in GALLERY:
|
||||
assert caption and "\u2014" not in caption, name
|
||||
assert not any(word in caption.lower() for word in BANNED), name
|
||||
assert GALLERY[0][0] == "flyer-elite-twice.jpg"
|
||||
|
||||
|
||||
def test_retire_media_soft_deletes_once(app_server):
|
||||
from molodetz.database import db
|
||||
from molodetz.database.media import media_by_kind, retire_media, upsert_media
|
||||
|
||||
upsert_media("story.jpg", "meme", "Old Dutch story", 999, 1080, 1350, None, None, None)
|
||||
assert retire_media("story.jpg") is True
|
||||
assert retire_media("story.jpg") is False
|
||||
row = db["media_items"].find_one(filename="story.jpg")
|
||||
assert row["deleted_at"] and row["deleted_by"] == "system"
|
||||
assert "story.jpg" not in {item["filename"] for item in media_by_kind("meme")}
|
||||
|
||||
Reference in New Issue
Block a user