# Path: staticgen/exceptions.py
# class StaticgenError(Exception):
#     pass
# 
# Path: staticgen/staticgen_pool.py
# class StaticgenPool(object):
#     def __init__(self):
#         self._discovered = False
#         self.modules = {}
# 
#     def log_error(self, message):
#         logger.error(message)
#         if not settings.STATICGEN_FAIL_SILENTLY:
#             raise StaticgenError(message)
# 
#     def register(self, cls):
#         from .staticgen_views import StaticgenView
#         if not issubclass(cls, StaticgenView):
#             message = _('Staticgen Views must inherit '
#                         '"staticgen.staticgen_views.StaticgenView", '
#                         '{cls} does not').format(cls=cls)
#             self.log_error(message)
#             return False  # pragma: no cover
# 
#         name = '{module}.{name}'.format(module=cls.__module__, name=cls.__name__)
#         if name in self.modules.keys():
#             message = _('"{name}" a Staticgen view with this name '
#                         'is already registered'.format(name=name))
#             self.log_error(message)
#             return False  # pragma: no cover
# 
#         self.modules[name] = cls()
# 
#     def autodiscover(self):
#         if self._discovered:  # pragma: no cover
#             return
# 
#         for app in settings.INSTALLED_APPS:
#             staticgen_views = app + '.staticgen_views'
#             try:
#                 import_module(staticgen_views)
#             except ImportError:
#                 pass
#         self._discovered = True
# 
#     def get_urls(self):
#         urls = []
#         for name, module in self.modules.items():
#             urls.extend(module.get_urls())
# 
#         urls = list(set(urls))
#         urls.sort()
#         return urls
# 
# Path: example/staticgen_views.py
# class ExampleStaticView(StaticgenView):
# 
#     def items(self):
#         return (
#             'homepage',
#             'error_page',
#             'redirect_home',
#             'django.contrib.sitemaps.views.sitemap',
#         )


from django.test import TestCase, override_settings
from staticgen.exceptions import StaticgenError
from staticgen.staticgen_pool import StaticgenPool
from example.staticgen_views import ExampleStaticView
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals





class TestStaticgenPool(TestCase):

    def setUp(self):
        self.staticgen_pool = StaticgenPool()

    @override_settings(STATICGEN_FAIL_SILENTLY=False)
    def test_register(self):
        self.staticgen_pool.register(ExampleStaticView)
        self.assertTrue('example.staticgen_views.ExampleStaticView' in self.staticgen_pool.modules)

# Path: staticgen/exceptions.py
# class StaticgenError(Exception):
#     pass
# 
# Path: staticgen/staticgen_pool.py
# class StaticgenPool(object):
#     def __init__(self):
#         self._discovered = False
#         self.modules = {}
# 
#     def log_error(self, message):
#         logger.error(message)
#         if not settings.STATICGEN_FAIL_SILENTLY:
#             raise StaticgenError(message)
# 
#     def register(self, cls):
#         from .staticgen_views import StaticgenView
#         if not issubclass(cls, StaticgenView):
#             message = _('Staticgen Views must inherit '
#                         '"staticgen.staticgen_views.StaticgenView", '
#                         '{cls} does not').format(cls=cls)
#             self.log_error(message)
#             return False  # pragma: no cover
# 
#         name = '{module}.{name}'.format(module=cls.__module__, name=cls.__name__)
#         if name in self.modules.keys():
#             message = _('"{name}" a Staticgen view with this name '
#                         'is already registered'.format(name=name))
#             self.log_error(message)
#             return False  # pragma: no cover
# 
#         self.modules[name] = cls()
# 
#     def autodiscover(self):
#         if self._discovered:  # pragma: no cover
#             return
# 
#         for app in settings.INSTALLED_APPS:
#             staticgen_views = app + '.staticgen_views'
#             try:
#                 import_module(staticgen_views)
#             except ImportError:
#                 pass
#         self._discovered = True
# 
#     def get_urls(self):
#         urls = []
#         for name, module in self.modules.items():
#             urls.extend(module.get_urls())
# 
#         urls = list(set(urls))
#         urls.sort()
#         return urls
# 
# Path: example/staticgen_views.py
# class ExampleStaticView(StaticgenView):
# 
#     def items(self):
#         return (
#             'homepage',
#             'error_page',
#             'redirect_home',
#             'django.contrib.sitemaps.views.sitemap',
#         )


# Path: tests/test_staticgen_pool.py
from django.test import TestCase, override_settings
from staticgen.exceptions import StaticgenError
from staticgen.staticgen_pool import StaticgenPool
from example.staticgen_views import ExampleStaticView

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals





class TestStaticgenPool(TestCase):

    def setUp(self):
        self.staticgen_pool = StaticgenPool()

    @override_settings(STATICGEN_FAIL_SILENTLY=False)
    def test_register(self):
        self.staticgen_pool.register(ExampleStaticView)
        self.assertTrue('example.staticgen_views.ExampleStaticView' in self.staticgen_pool.modules)

        self.assertRaises(StaticgenError, self.staticgen_pool.register, ExampleStaticView)