# Path: feincms/contents.py

# 
# Path: feincms/module/medialibrary/contents.py
# class MediaFileContent(ContentWithMediaFile):
#     """
#     Rehashed, backwards-incompatible media file content which does not contain
#     the problems from v1 anymore.
# 
#     Create a media file content as follows::
# 
#         from feincms.content.medialibrary.models import MediaFileContent
#         Page.create_content_type(MediaFileContent, TYPE_CHOICES=(
#             ('default', _('Default')),
#             ('lightbox', _('Lightbox')),
#             ('whatever', _('Whatever')),
#             ))
# 
#     For a media file of type 'image' and type 'lightbox', the following
#     templates are tried in order:
# 
#     * content/mediafile/image_lightbox.html
#     * content/mediafile/image.html
#     * content/mediafile/lightbox.html
#     * content/mediafile/default.html
# 
#     The context contains ``content`` and ``request`` (if available).
#     """
# 
#     feincms_item_editor_inline = MediaFileContentInline
# 
#     class Meta:
#         abstract = True
#         verbose_name = _("media file")
#         verbose_name_plural = _("media files")
# 
#     @classmethod
#     def initialize_type(cls, TYPE_CHOICES=None):
#         if TYPE_CHOICES is None:
#             raise ImproperlyConfigured(
#                 "You have to set TYPE_CHOICES when" " creating a %s" % cls.__name__
#             )
# 
#         cls.add_to_class(
#             "type",
#             models.CharField(
#                 _("type"),
#                 max_length=20,
#                 choices=TYPE_CHOICES,
#                 default=TYPE_CHOICES[0][0],
#             ),
#         )
# 
#     def render(self, **kwargs):
#         return (
#             [
#                 f"content/mediafile/{self.mediafile.type}_{self.type}.html",
#                 "content/mediafile/%s.html" % self.mediafile.type,
#                 "content/mediafile/%s.html" % self.type,
#                 "content/mediafile/default.html",
#             ],
#             {"content": self},
#         )
# 
# Path: tests/testapp/tests/test_stuff.py
# class Empty:
#     """
#     Helper class to use as request substitute (or whatever)
#     """


from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.test import TestCase
from testapp.models import ExampleCMSBase, ExampleCMSBase2
from feincms.contents import RawContent, RichTextContent
from feincms.module.medialibrary.contents import MediaFileContent
from .test_stuff import Empty
            lambda: ExampleCMSBase.create_content_type(MediaFileContent),
        )

    def test_05_non_abstract_content_type(self):
        # Should not be able to create a content type from a non-abstract base
        # type
        class TestContentType(models.Model):
            pass

        self.assertRaises(
            ImproperlyConfigured,
            lambda: ExampleCMSBase.create_content_type(TestContentType),
        )

    def test_07_default_render_method(self):
        class SomethingElse(models.Model):
            class Meta:
                abstract = True

            def render_region(self):
                return "hello"

        type = ExampleCMSBase.create_content_type(SomethingElse)
        obj = type()
        self.assertRaises(NotImplementedError, lambda: obj.render())

        obj.region = "region"
        self.assertEqual(obj.render(), "hello")

    def test_08_creating_two_content_types_in_same_application(self):

# Path: feincms/contents.py

# 
# Path: feincms/module/medialibrary/contents.py
# class MediaFileContent(ContentWithMediaFile):
#     """
#     Rehashed, backwards-incompatible media file content which does not contain
#     the problems from v1 anymore.
# 
#     Create a media file content as follows::
# 
#         from feincms.content.medialibrary.models import MediaFileContent
#         Page.create_content_type(MediaFileContent, TYPE_CHOICES=(
#             ('default', _('Default')),
#             ('lightbox', _('Lightbox')),
#             ('whatever', _('Whatever')),
#             ))
# 
#     For a media file of type 'image' and type 'lightbox', the following
#     templates are tried in order:
# 
#     * content/mediafile/image_lightbox.html
#     * content/mediafile/image.html
#     * content/mediafile/lightbox.html
#     * content/mediafile/default.html
# 
#     The context contains ``content`` and ``request`` (if available).
#     """
# 
#     feincms_item_editor_inline = MediaFileContentInline
# 
#     class Meta:
#         abstract = True
#         verbose_name = _("media file")
#         verbose_name_plural = _("media files")
# 
#     @classmethod
#     def initialize_type(cls, TYPE_CHOICES=None):
#         if TYPE_CHOICES is None:
#             raise ImproperlyConfigured(
#                 "You have to set TYPE_CHOICES when" " creating a %s" % cls.__name__
#             )
# 
#         cls.add_to_class(
#             "type",
#             models.CharField(
#                 _("type"),
#                 max_length=20,
#                 choices=TYPE_CHOICES,
#                 default=TYPE_CHOICES[0][0],
#             ),
#         )
# 
#     def render(self, **kwargs):
#         return (
#             [
#                 f"content/mediafile/{self.mediafile.type}_{self.type}.html",
#                 "content/mediafile/%s.html" % self.mediafile.type,
#                 "content/mediafile/%s.html" % self.type,
#                 "content/mediafile/default.html",
#             ],
#             {"content": self},
#         )
# 
# Path: tests/testapp/tests/test_stuff.py
# class Empty:
#     """
#     Helper class to use as request substitute (or whatever)
#     """


# Path: tests/testapp/tests/test_cms.py
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.test import TestCase
from testapp.models import ExampleCMSBase, ExampleCMSBase2
from feincms.contents import RawContent, RichTextContent
from feincms.module.medialibrary.contents import MediaFileContent
from .test_stuff import Empty

            lambda: ExampleCMSBase.create_content_type(MediaFileContent),
        )

    def test_05_non_abstract_content_type(self):
        # Should not be able to create a content type from a non-abstract base
        # type
        class TestContentType(models.Model):
            pass

        self.assertRaises(
            ImproperlyConfigured,
            lambda: ExampleCMSBase.create_content_type(TestContentType),
        )

    def test_07_default_render_method(self):
        class SomethingElse(models.Model):
            class Meta:
                abstract = True

            def render_region(self):
                return "hello"

        type = ExampleCMSBase.create_content_type(SomethingElse)
        obj = type()
        self.assertRaises(NotImplementedError, lambda: obj.render())

        obj.region = "region"
        self.assertEqual(obj.render(), "hello")

    def test_08_creating_two_content_types_in_same_application(self):

        ExampleCMSBase.create_content_type(RawContent)