# Path: achilles/common.py
# class BaseLibrary(object):
#     """
#     Base register library, provides decorator functions to register
#     items of any type.
# 
#     All items are registered using a name to uniquely identify them
# 
#     This register library is namespaced, so every new instance of it
#     gets registered under the given namespace. This will avoid
#     collisions between apps
#     """
#     namespace_separator = ':'
# 
#     def __init__(self, namespace):
#         # global namespaced register
#         if not hasattr(type(self), 'registers'):
#             type(self).registers = {}
# 
#         # Register the instanced library
#         if namespace in type(self).registers:
#             library = type(self).registers[namespace]
#             raise ValueError("An namespace with name "
#                              "'%s' is already registered in '%s'" %
#                              (namespace, library.__module__))
# 
#         type(self).registers[namespace] = self
#         self.namespace = namespace
#         self.items = {}
# 
#     def get(self, name):
#         if name not in self.items:
#             raise KeyError("'%s' item doesn't exists" % name)
#         return self.items[name]
# 
#     @classmethod
#     def get_global(cls, name):
#         if cls.namespace_separator in name:
#             namespace, name = name.split(cls.namespace_separator, 1)
#         else:
#             namespace = None
#         if namespace not in cls.registers:
#             raise KeyError("'%s' namespace doesn't exists. "
#                            "Avaible namespaces are: %s"
#                            % (namespace, cls.registers.keys()))
#         register = cls.registers[namespace]
#         try:
#             return register.get(name)
#         except KeyError:
#             raise KeyError("'%s' doesn't exists" % name)
# 
#     def register(self, name=None):
#         if name is None:
#             return self._register
#         elif callable(name):
#             func = name
#             name = getattr(name, '_decorated_function', name).__name__
#             return self._register(func, name)
#         else:
#             def dec(func):
#                 return self._register(func, name)
#             return dec
# 
#     def _register(self, func, name=None):
#         name = name or getattr(func, '_decorated_function', func).__name__
#         func.register_name = ':'.join([self.namespace or '', name])
#         self.items[name] = func
#         return func
# 
# def achilles_plugins():
#     """
#     Return a dict of the enabled plugins with achilles namespace as keys
#     """
#     return getattr(settings, 'ACHILLES_PLUGINS',
#                    {
#                        'blocks': 'achilles.blocks',
#                        'actions': 'achilles.actions',
#                        'console': 'achilles.console',
#                        'redirect': 'achilles.redirect',
#                        'messages': 'achilles.messages',
#                    })
# 
# def achilles_renders():
#     """
#     Return a dict of enabled plugin' render functions
#     """
#     return {k: import_by_path('%s.render' % p)
#             for k, p in achilles_plugins().items()}


from django.test import TestCase
from achilles.common import (BaseLibrary,
                             achilles_plugins,
                             achilles_renders)



class Library(BaseLibrary):
    pass


class AchillesRendersTests(TestCase):

    def test_achilles_renders(self):

# Path: achilles/common.py
# class BaseLibrary(object):
#     """
#     Base register library, provides decorator functions to register
#     items of any type.
# 
#     All items are registered using a name to uniquely identify them
# 
#     This register library is namespaced, so every new instance of it
#     gets registered under the given namespace. This will avoid
#     collisions between apps
#     """
#     namespace_separator = ':'
# 
#     def __init__(self, namespace):
#         # global namespaced register
#         if not hasattr(type(self), 'registers'):
#             type(self).registers = {}
# 
#         # Register the instanced library
#         if namespace in type(self).registers:
#             library = type(self).registers[namespace]
#             raise ValueError("An namespace with name "
#                              "'%s' is already registered in '%s'" %
#                              (namespace, library.__module__))
# 
#         type(self).registers[namespace] = self
#         self.namespace = namespace
#         self.items = {}
# 
#     def get(self, name):
#         if name not in self.items:
#             raise KeyError("'%s' item doesn't exists" % name)
#         return self.items[name]
# 
#     @classmethod
#     def get_global(cls, name):
#         if cls.namespace_separator in name:
#             namespace, name = name.split(cls.namespace_separator, 1)
#         else:
#             namespace = None
#         if namespace not in cls.registers:
#             raise KeyError("'%s' namespace doesn't exists. "
#                            "Avaible namespaces are: %s"
#                            % (namespace, cls.registers.keys()))
#         register = cls.registers[namespace]
#         try:
#             return register.get(name)
#         except KeyError:
#             raise KeyError("'%s' doesn't exists" % name)
# 
#     def register(self, name=None):
#         if name is None:
#             return self._register
#         elif callable(name):
#             func = name
#             name = getattr(name, '_decorated_function', name).__name__
#             return self._register(func, name)
#         else:
#             def dec(func):
#                 return self._register(func, name)
#             return dec
# 
#     def _register(self, func, name=None):
#         name = name or getattr(func, '_decorated_function', func).__name__
#         func.register_name = ':'.join([self.namespace or '', name])
#         self.items[name] = func
#         return func
# 
# def achilles_plugins():
#     """
#     Return a dict of the enabled plugins with achilles namespace as keys
#     """
#     return getattr(settings, 'ACHILLES_PLUGINS',
#                    {
#                        'blocks': 'achilles.blocks',
#                        'actions': 'achilles.actions',
#                        'console': 'achilles.console',
#                        'redirect': 'achilles.redirect',
#                        'messages': 'achilles.messages',
#                    })
# 
# def achilles_renders():
#     """
#     Return a dict of enabled plugin' render functions
#     """
#     return {k: import_by_path('%s.render' % p)
#             for k, p in achilles_plugins().items()}


# Path: achilles/tests/test_common.py
from django.test import TestCase
from achilles.common import (BaseLibrary,
                             achilles_plugins,
                             achilles_renders)




class Library(BaseLibrary):
    pass


class AchillesRendersTests(TestCase):

    def test_achilles_renders(self):

        plugins = achilles_plugins()