'Test that using CMS_TEMPLATES_DIR both template list and template labels are extracted from the new directory'

@override_settings(CMS_TEMPLATES_DIR=GOOD_PATH)
def test_custom_templates(self):

    config_path = os.path.join(settings.CMS_TEMPLATES_DIR, '__init__.py')
    with open(config_path, 'r') as openfile:
        mod = load_module('mod', openfile, config_path, ('m', 'r', PY_SOURCE))
    original_labels = [force_text(_(template[1])) for template in mod.TEMPLATES.items()]
    original_files = [os.path.join(PATH_PREFIX, template[0].strip()) for template in mod.TEMPLATES.items()]
    templates = get_cms_setting('TEMPLATES')
    self.assertEqual(len(templates), 3)
    labels = [force_text(template[1]) for template in templates]
    files = [template[0] for template in templates]
    if get_cms_setting('TEMPLATE_INHERITANCE'):
        original_labels.append(force_text(_('Inherit    the    template    of    the    nearest    ancestor')))
        original_files.append(constants.TEMPLATE_INHERITANCE_MAGIC)
    self.assertEqual(set(labels), set(original_labels))
    self.assertEqual(set(files), set(original_files))
