# Path: privagal/gallery/factories.py
# class ImageFactory(factory.DjangoModelFactory):
# 
#     class Meta:
#         model = get_image_model()
# 
#     title = factory.Faker('sentence', locale=locale)
#     file = factory.django.ImageField()
# 
# Path: privagal/core/templatetags/privagalcore_tags.py
# @register.simple_tag()
# def image_url(image, filter_spec):
#     signature = generate_signature(image.id, filter_spec)
#     url = reverse(
#         'wagtailimages_serve',
#         args=(signature, image.id, filter_spec)
#     )
#     url += image.file.name[len('original_images/'):]
#     return url


from django.conf import settings
from django.test import TestCase
from privagal.gallery.factories import ImageFactory
from ..templatetags.privagalcore_tags import image_url
# -*- coding: utf-8 -*-
from __future__ import unicode_literals





class ImageUrlTestCase(TestCase):

    def test_image_url(self):
        image = ImageFactory()
        filter_spec = 'max200-150'
        url = image_url(image, filter_spec)

        self.assertRegexpMatches(
            url,
            '^{media}images/(.)*/{filter_spec}/{filename}$'.format(
                media=settings.MEDIA_URL,
                filter_spec=filter_spec,

# Path: privagal/gallery/factories.py
# class ImageFactory(factory.DjangoModelFactory):
# 
#     class Meta:
#         model = get_image_model()
# 
#     title = factory.Faker('sentence', locale=locale)
#     file = factory.django.ImageField()
# 
# Path: privagal/core/templatetags/privagalcore_tags.py
# @register.simple_tag()
# def image_url(image, filter_spec):
#     signature = generate_signature(image.id, filter_spec)
#     url = reverse(
#         'wagtailimages_serve',
#         args=(signature, image.id, filter_spec)
#     )
#     url += image.file.name[len('original_images/'):]
#     return url


# Path: privagal/core/tests/test_templatetags.py
from django.conf import settings
from django.test import TestCase
from privagal.gallery.factories import ImageFactory
from ..templatetags.privagalcore_tags import image_url

# -*- coding: utf-8 -*-
from __future__ import unicode_literals





class ImageUrlTestCase(TestCase):

    def test_image_url(self):
        image = ImageFactory()
        filter_spec = 'max200-150'
        url = image_url(image, filter_spec)

        self.assertRegexpMatches(
            url,
            '^{media}images/(.)*/{filter_spec}/{filename}$'.format(
                media=settings.MEDIA_URL,
                filter_spec=filter_spec,

                filename=image.filename,