# -*- coding: utf-8 -*-

from django.conf import settings
from django.test import TestCase

from mtp.apps.themes.factories import ThemeFactory


class ThemeModelTestCase(TestCase):
    """Test case that tests the ``Theme`` model."""

    def setUp(self):
        super(ThemeModelTestCase, self).setUp()

        self.theme = ThemeFactory()

    def test_requires_images_creation(self):
        """Test that requires images and their hash are created."""

        # Test image creation
        self.assertEqual(self.theme.background_image.name, settings.THEME_BACKGROUND_IMAGE)
        self.assertEqual(self.theme.background_image_diffusion.name,
                         settings.THEME_BACKGROUND_IMAGE_DIFFUSION)
        self.assertEqual(self.theme.header_image.name, settings.THEME_HEADER_IMAGE)
        self.assertEqual(self.theme.home_diffusion_image.name, settings.THEME_HOME_DIFFUSION_IMAGE)

        # Test hash creation, if url image is not defined, hash image will be not computed so
        # don't need to test it.
        if settings.THEME_BACKGROUND_IMAGE:
            self.assertNotEqual(self.theme.background_image_hash, "")
        if settings.THEME_BACKGROUND_IMAGE_DIFFUSION:
            self.assertNotEqual(self.theme.background_image_diffusion_hash, "")
        if settings.THEME_HEADER_IMAGE:
            self.assertNotEqual(self.theme.header_image_hash, "")
        if settings.THEME_HOME_DIFFUSION_IMAGE:
            self.assertNotEqual(self.theme.home_diffusion_image_hash, "")
