"""This module holds test cases for the ``photostories`` app."""

from mtp.apps.common.tests.test_cases import MTPTestCase, WithMediaOnDisk

from ..factories import PhotoFactory, StripFactory, PhotostoryFactory


class PhotostoryTestCase(MTPTestCase, WithMediaOnDisk):
    """Base test for models in ``strips`` app."""

    @classmethod
    def setUpTestData(cls):
        """Create data to test ``strips`` app."""

        super().setUpTestData()

        cls.photostory = PhotostoryFactory(
            training=cls.training
        )

        cls.photostory_live = PhotostoryFactory(
            training=None,
            session=cls.training_session
        )

        cls.photostories = [cls.photostory, cls.photostory_live]

        # Create 2 strips with photos for the photostory
        cls.strips = StripFactory.create_batch(
            2,
            photostory=cls.photostory,
            session=cls.training_session,
            owner=cls.trainee,
        )

        for strip in cls.strips:
            PhotoFactory.create_batch(3, strip=strip)

        # Create 2 strips with photos for the live photostory
        cls.strips_live = StripFactory.create_batch(
            2,
            photostory=cls.photostory_live,
            session=cls.training_session,
        )

        for strip in cls.strips_live:
            PhotoFactory.create_batch(3, strip=strip)

        cls.strip = cls.strips[0]
        cls.strip_live = cls.strips_live[0]

        cls.photo = cls.strip.photos.first()
