2026-06-03 08:11:24 +03:00
|
|
|
from types import SimpleNamespace
|
|
|
|
|
|
2026-06-04 15:44:25 +01:00
|
|
|
from tests.helpers.cli_loader import load_script
|
|
|
|
|
from tests.helpers.db_stubs import make_core_db_stub
|
2026-06-03 08:11:24 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_album_image_count_handles_missing_relationship(monkeypatch):
|
2026-06-04 15:44:25 +01:00
|
|
|
make_core_db_stub(monkeypatch, models=["GalleryImage", "GalleryAlbum"])
|
|
|
|
|
cli = load_script("odysseus-gallery")
|
2026-06-03 08:11:24 +03:00
|
|
|
|
|
|
|
|
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
|