Ejemplo n.º 1
0
 def test_import_module_raises_improperly_configured(self):
     """We can only import attributes from modules, not modules directly"""
     with self.assertRaises(ImproperlyConfigured) as cm:
         import_element('fiber')
     self.assertEqual(
         str(cm.exception),
         'Error importing fiber: fiber doesn\'t look like a module path')
Ejemplo n.º 2
0
 def test_import_invalid_module_raises_improperly_configured(self):
     """Fail trying to import a missing module"""
     with self.assertRaises(ImproperlyConfigured) as cm:
         import_element("fiber.missing_module.missing_attribute")
     self.assertEqual(
         str(cm.exception), "Error importing fiber.missing_module.missing_attribute: No module named missing_module"
     )
Ejemplo n.º 3
0
 def test_import_invalid_module_raises_improperly_configured(self):
     """Fail trying to import a missing module"""
     with self.assertRaises(ImproperlyConfigured) as cm:
         import_element('fiber.missing_module.missing_attribute')
     self.assertRegexpMatches(
         str(cm.exception),
         r'Error importing fiber.missing_module.missing_attribute: No module named .+'
     )
Ejemplo n.º 4
0
 def test_import_invalid_attribute_raises_improperly_configured(self):
     """Fail trying to import a missing attribute"""
     with self.assertRaises(ImproperlyConfigured) as cm:
         import_element("fiber.missing_attribute")
     self.assertEqual(
         str(cm.exception),
         'Error importing fiber.missing_attribute: Module "fiber.missing_attribute" does not define a "missing_attribute" attribute/class',
     )
Ejemplo n.º 5
0
 def test_import_invalid_attribute_raises_improperly_configured(self):
     """Fail trying to import a missing attribute"""
     with self.assertRaises(ImproperlyConfigured) as cm:
         import_element('fiber.missing_attribute')
     msgs = [
         'Error importing fiber.missing_attribute: Module "fiber.missing_attribute" does not define a "missing_attribute" attribute/class',
         'Error importing fiber.missing_attribute: Module "fiber" does not define a "missing_attribute" attribute/class',  # Django 1.8 and later
     ]
     self.assertIn(str(cm.exception), msgs)
Ejemplo n.º 6
0
 def test_import_invalid_attribute_raises_improperly_configured(self):
     """Fail trying to import a missing attribute"""
     with self.assertRaises(ImproperlyConfigured) as cm:
         import_element('fiber.missing_attribute')
     msgs = [
         'Error importing fiber.missing_attribute: Module "fiber.missing_attribute" does not define a "missing_attribute" attribute/class',
         'Error importing fiber.missing_attribute: Module "fiber" does not define a "missing_attribute" attribute/class',  # Django 1.8 and later
     ]
     self.assertIn(str(cm.exception), msgs)
Ejemplo n.º 7
0
 def __init__(self, *args, **kwargs):
     super(AdminPageMiddleware, self).__init__(*args, **kwargs)
     self.editor_settings = import_element(EDITOR)
Ejemplo n.º 8
0
 def __init__(self):
     self.editor_settings = import_element(EDITOR)
Ejemplo n.º 9
0
from fiber.utils.import_util import import_element
from fiber.app_settings import EDITOR


editor = import_element(EDITOR)
renderer = editor.get('renderer', None)


def get_editor_field_name(html_field_name):
    """
    Returns markup or html field name, depending on editor.
    Input is html field_name:

    get_editor_field_name('content_html')

    returns: 'content_html' or 'content_markup'
    """
    if renderer:
        return html_field_name.replace('_html', '_markup')
    else:
        return html_field_name
Ejemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     super(AdminPageMiddleware, self).__init__(*args, **kwargs)
     self.editor_settings = import_element(EDITOR)
Ejemplo n.º 11
0
 def test_import_module_raises_improperly_configured(self):
     """We can only import attributes from modules, not modules directly"""
     with self.assertRaises(ImproperlyConfigured) as cm:
         import_element('fiber')
     self.assertEqual(str(cm.exception), 'Error importing fiber: fiber doesn\'t look like a module path')
Ejemplo n.º 12
0
 def test_import_element(self):
     """Import TestClass by name"""
     path = '.'.join([self.__module__, 'TestClass'])
     self.assertEqual(import_element(path), TestClass)
Ejemplo n.º 13
0
 def __init__(self):
     self.editor_settings = import_element(EDITOR)
Ejemplo n.º 14
0
 def test_import_element(self):
     """Import TestClass by name"""
     path = '.'.join([self.__module__, 'TestClass'])
     self.assertEqual(import_element(path), TestClass)
Ejemplo n.º 15
0
from fiber.app_settings import EDITOR
from fiber.utils.import_util import import_element


editor = import_element(EDITOR)
renderer = editor.get('renderer', None)


def get_editor_field_name(html_field_name):
    """
    Returns markup or html field name, depending on editor.
    Input is html field_name:

    get_editor_field_name('content_html')

    returns: 'content_html' or 'content_markup'
    """
    if renderer:
        return html_field_name.replace('_html', '_markup')
    else:
        return html_field_name