Files
logimage-generator/tests/infrastructure/test_unsplash_source.py
T
Vincent Bourdon 5a03f8a38d import initial
2026-06-10 10:21:18 +02:00

28 lines
935 B
Python

import os
import pytest
from logimage.infrastructure.image.unsplash_source import UnsplashImageSource
from logimage.domain.value_objects.image_data import ImageData
@pytest.mark.integration
def test_fetch_returns_image_data() -> None:
api_key = os.environ.get("UNSPLASH_ACCESS_KEY")
if not api_key:
pytest.skip("UNSPLASH_ACCESS_KEY not set")
source = UnsplashImageSource(api_key=api_key)
result = source.fetch()
assert isinstance(result, ImageData)
assert len(result.content) > 1000
assert isinstance(result.title, str)
@pytest.mark.integration
def test_fetch_with_theme_returns_image_data() -> None:
api_key = os.environ.get("UNSPLASH_ACCESS_KEY")
if not api_key:
pytest.skip("UNSPLASH_ACCESS_KEY not set")
source = UnsplashImageSource(api_key=api_key)
result = source.fetch(theme="forest")
assert isinstance(result, ImageData)
assert len(result.content) > 1000