Files
odysseus/tests/test_gallery_cli_album_count.py
Alexandre Teixeira dd1fa7e1c4 refactor(tests): add shared CLI test helpers
Adds shared test helpers for CLI script loading and scoped core.database stubs, then converts a low-conflict pilot set of CLI tests. Part of #2523.
2026-06-04 15:44:25 +01:00

14 lines
541 B
Python

from types import SimpleNamespace
from tests.helpers.cli_loader import load_script
from tests.helpers.db_stubs import make_core_db_stub
def test_album_image_count_handles_missing_relationship(monkeypatch):
make_core_db_stub(monkeypatch, models=["GalleryImage", "GalleryAlbum"])
cli = load_script("odysseus-gallery")
assert cli._album_image_count(SimpleNamespace(images=[1, 2])) == 2
assert cli._album_image_count(SimpleNamespace(images=None)) == 0
assert cli._album_image_count(SimpleNamespace(images=object())) == 0