import horizon from openstack_dashboard.dashboards.admin.info import panel as info_panel from openstack_dashboard.test import helpers as test from openstack_dashboard.test.test_panels.plugin_panel \ import panel as plugin_panel import openstack_dashboard.test.test_plugins.panel_config from openstack_dashboard.utils import settings as util_settings HORIZON_CONFIG = copy.deepcopy(settings.HORIZON_CONFIG) INSTALLED_APPS = list(settings.INSTALLED_APPS) util_settings.update_dashboards([ openstack_dashboard.test.test_plugins.panel_config, ], HORIZON_CONFIG, INSTALLED_APPS) @override_settings(HORIZON_CONFIG=HORIZON_CONFIG, INSTALLED_APPS=INSTALLED_APPS) class PanelPluginTests(test.PluginTestCase): def test_add_panel(self): dashboard = horizon.get_dashboard("admin") self.assertIn(plugin_panel.PluginPanel, [p.__class__ for p in dashboard.get_panels()]) def test_remove_panel(self): dashboard = horizon.get_dashboard("admin") self.assertNotIn(info_panel.Info, [p.__class__ for p in dashboard.get_panels()])
# populate HORIZON_CONFIG with auto-discovered JavaScript sources, mock files, # specs files and external templates. settings_utils.find_static_files(HORIZON_CONFIG, AVAILABLE_THEMES, THEME_COLLECTION_DIR, ROOT_PATH) # Load the pluggable dashboard settings import openstack_dashboard.enabled import openstack_dashboard.local.enabled INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings_utils.update_dashboards( [ openstack_dashboard.enabled, openstack_dashboard.local.enabled, ], HORIZON_CONFIG, INSTALLED_APPS, ) INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS NG_TEMPLATE_CACHE_AGE = NG_TEMPLATE_CACHE_AGE if not DEBUG else 0 # This base context objects gets added to the offline context generator # for each theme configured. HORIZON_COMPRESS_OFFLINE_CONTEXT_BASE = { 'WEBROOT': WEBROOT, 'STATIC_URL': STATIC_URL, 'HORIZON_CONFIG': HORIZON_CONFIG, 'NG_TEMPLATE_CACHE_AGE': NG_TEMPLATE_CACHE_AGE, }
# pylint: disable=ungrouped-imports from horizon.utils import secret_key SECRET_KEY = secret_key.generate_or_read_from_file( os.path.join(LOCAL_PATH, '.secret_key_store')) # populate HORIZON_CONFIG with auto-discovered JavaScript sources, mock files, # specs files and external templates. settings_utils.find_static_files(HORIZON_CONFIG, AVAILABLE_THEMES, THEME_COLLECTION_DIR, ROOT_PATH) INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings_utils.update_dashboards( [ enabled, local_enabled, ], HORIZON_CONFIG, INSTALLED_APPS, ) INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS # Include xstatic_modules specified in plugin XSTATIC_MODULES += HORIZON_CONFIG['xstatic_modules'] # Discover all the xstatic module entry points to embed in our HTML STATICFILES_DIRS += settings_utils.get_xstatic_dirs(XSTATIC_MODULES, HORIZON_CONFIG) # This base context objects gets added to the offline context generator # for each theme configured. HORIZON_COMPRESS_OFFLINE_CONTEXT_BASE = {
'flavors_panel': False, 'roles_panel': False, } STATICFILES_DIRS = settings_utils.get_xstatic_dirs( settings_utils.BASE_XSTATIC_MODULES, HORIZON_CONFIG ) # Load the pluggable dashboard settings import openstack_dashboard.enabled INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings_utils.update_dashboards( [ openstack_dashboard.enabled, ], HORIZON_CONFIG, INSTALLED_APPS, ) OPENSTACK_PROFILER = {'enabled': False} settings_utils.find_static_files(HORIZON_CONFIG, AVAILABLE_THEMES, THEME_COLLECTION_DIR, ROOT_PATH) # Set to 'legacy' or 'direct' to allow users to upload images to glance via # Horizon server. When enabled, a file form field will appear on the create # image form. If set to 'off', there will be no file form field on the create # image form. See documentation for deployment considerations. HORIZON_IMAGES_UPLOAD_MODE = 'legacy'
'openstack_dashboard.local.enabled', 'watcher_dashboard.enabled', ] dashboard_modules = [] # All dashboards must be enabled for the namespace to get registered, which is # needed by the unit tests. for module_name in dashboard_module_names: module = importlib.import_module(module_name) dashboard_modules.append(module) for submodule in six.itervalues(settings_utils.import_submodules(module)): if getattr(submodule, 'DISABLED', None): delattr(submodule, 'DISABLED') INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings_utils.update_dashboards( dashboard_modules, HORIZON_CONFIG, INSTALLED_APPS ) # Set to True to allow users to upload images to glance via Horizon server. # When enabled, a file form field will appear on the create image form. # See documentation for deployment considerations. HORIZON_IMAGES_ALLOW_UPLOAD = True AVAILABLE_REGIONS = [ ('http://localhost:5000/v2.0', 'local'), ('http://remote:5000/v2.0', 'remote'), ] OPENSTACK_API_VERSIONS = { "identity": 3 }
from openstack_dashboard.test.test_plugins import panel_config from openstack_dashboard.utils import settings as util_settings HORIZON_CONFIG = copy.deepcopy(settings.HORIZON_CONFIG) INSTALLED_APPS = list(settings.INSTALLED_APPS) # NOTE: Ensure dashboards and default_dashboard are not included in # HORIZON_CONFIG to ensure warning messages from update_dashboards below. HORIZON_CONFIG.pop('dashboards', None) HORIZON_CONFIG.pop('default_dashboard', None) HORIZON_CONFIG.pop('js_files', None) HORIZON_CONFIG.pop('js_spec_files', None) HORIZON_CONFIG.pop('scss_files', None) util_settings.update_dashboards([ panel_config, ], HORIZON_CONFIG, INSTALLED_APPS) @override_settings(HORIZON_CONFIG=HORIZON_CONFIG, INSTALLED_APPS=INSTALLED_APPS) class PanelPluginTests(test.PluginTestCase): urls = 'openstack_dashboard.test.extensible_header_urls' def test_add_panel(self): dashboard = horizon.get_dashboard("admin") panel_group = dashboard.get_panel_group('admin') # Check that the panel is in its configured dashboard. self.assertIn(plugin_panel.PluginPanel, [p.__class__ for p in dashboard.get_panels()]) # Check that the panel is in its configured panel group.
MEDIA_URL = WEBROOT + 'media/' STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static')) STATIC_URL = WEBROOT + 'static/' STATICFILES_DIRS = get_staticfiles_dirs(WEBROOT) CUSTOM_THEME = os.path.join(ROOT_PATH, CUSTOM_THEME_PATH) STATICFILES_DIRS.append(('custom', CUSTOM_THEME), ) import cloudvalidation.enabled from openstack_dashboard.utils import settings INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings.update_dashboards( [ cloudvalidation.enabled, ], HORIZON_CONFIG, INSTALLED_APPS, ) INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS # Ensure that we always have a SECRET_KEY set, even when no local_settings.py # file is present. See local_settings.py.example for full documentation on the # horizon.utils.secret_key module and its use. if not SECRET_KEY: if not LOCAL_PATH: LOCAL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'local') from horizon.utils import secret_key SECRET_KEY = secret_key.generate_or_read_from_file(
# Copyright 2015 Objectif Libre # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from openstack_dashboard.utils import settings as utils_settings from openstack_dashboard.settings import * import cloudkittydashboard.enabled ADD_INSTALLED_APPS = ['cloudkittydashboard'] DASHBOARD = '' utils_settings.update_dashboards( (cloudkittydashboard.enabled,), HORIZON_CONFIG, ADD_INSTALLED_APPS )
from openstack_dashboard.utils import settings import test.enabled from tuskar_ui.test.settings import * # noqa INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings.update_dashboards([test.enabled], HORIZON_CONFIG, INSTALLED_APPS)
'local') from horizon.utils import secret_key SECRET_KEY = secret_key.generate_or_read_from_file(os.path.join(LOCAL_PATH, '.secret_key_store')) # populate HORIZON_CONFIG with auto-discovered JavaScript sources, mock files, # specs files and external templates. settings_utils.find_static_files(HORIZON_CONFIG, AVAILABLE_THEMES, THEME_COLLECTION_DIR, ROOT_PATH) INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings_utils.update_dashboards( [ enabled, local_enabled, ], HORIZON_CONFIG, INSTALLED_APPS, ) INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS NG_TEMPLATE_CACHE_AGE = NG_TEMPLATE_CACHE_AGE if not DEBUG else 0 # Include xstatic_modules specified in plugin XSTATIC_MODULES += HORIZON_CONFIG['xstatic_modules'] # Discover all the xstatic module entry points to embed in our HTML STATICFILES_DIRS += settings_utils.get_xstatic_dirs( XSTATIC_MODULES, HORIZON_CONFIG) # This base context objects gets added to the offline context generator
def setUp(self): super(PluginPanelTests, self).setUp() util_settings.update_dashboards([panel_config, ], HORIZON_CONFIG, INSTALLED_APPS)
STATIC_URL = WEBROOT + 'static/' STATICFILES_DIRS = get_staticfiles_dirs(WEBROOT) CUSTOM_THEME = os.path.join(ROOT_PATH, CUSTOM_THEME_PATH) STATICFILES_DIRS.append( ('custom', CUSTOM_THEME), ) import cloudvalidation.enabled from openstack_dashboard.utils import settings INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings.update_dashboards( [ cloudvalidation.enabled, ], HORIZON_CONFIG, INSTALLED_APPS, ) INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS # Ensure that we always have a SECRET_KEY set, even when no local_settings.py # file is present. See local_settings.py.example for full documentation on the # horizon.utils.secret_key module and its use. if not SECRET_KEY: if not LOCAL_PATH: LOCAL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'local') from horizon.utils import secret_key SECRET_KEY = secret_key.generate_or_read_from_file(os.path.join(LOCAL_PATH,
STATICFILES_DIRS = settings_utils.get_xstatic_dirs( settings_utils.BASE_XSTATIC_MODULES, HORIZON_CONFIG ) # Load the pluggable dashboard settings import openstack_dashboard.contrib.developer.enabled import openstack_dashboard.enabled import openstack_dashboard.local.enabled INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings_utils.update_dashboards( [ openstack_dashboard.enabled, openstack_dashboard.local.enabled, openstack_dashboard.contrib.developer.enabled ], HORIZON_CONFIG, INSTALLED_APPS, ) # Remove this when the legacy panel is removed, along with its tests and # the stacks MappingsTests are updated with the new URL path. HORIZON_CONFIG['swift_panel'] = 'legacy' settings_utils.find_static_files(HORIZON_CONFIG, AVAILABLE_THEMES, THEME_COLLECTION_DIR, ROOT_PATH) # Set to 'legacy' or 'direct' to allow users to upload images to glance via # Horizon server. When enabled, a file form field will appear on the create # image form. If set to 'off', there will be no file form field on the create
from django.test.utils import override_settings import horizon from openstack_dashboard.test import helpers as test from openstack_dashboard.test.test_panels.plugin_panel \ import panel as plugin_panel import openstack_dashboard.test.test_plugins.panel_group_config from openstack_dashboard.utils import settings as util_settings PANEL_GROUP_SLUG = 'plugin_panel_group' HORIZON_CONFIG = copy.deepcopy(settings.HORIZON_CONFIG) INSTALLED_APPS = list(settings.INSTALLED_APPS) util_settings.update_dashboards([ openstack_dashboard.test.test_plugins.panel_group_config, ], HORIZON_CONFIG, INSTALLED_APPS) @override_settings(HORIZON_CONFIG=HORIZON_CONFIG, INSTALLED_APPS=INSTALLED_APPS) class PanelGroupPluginTests(test.PluginTestCase): def test_add_panel_group(self): dashboard = horizon.get_dashboard("admin") self.assertIsNotNone(dashboard.get_panel_group(PANEL_GROUP_SLUG)) def test_add_panel(self): dashboard = horizon.get_dashboard("admin") self.assertIn(plugin_panel.PluginPanel, [p.__class__ for p in dashboard.get_panels()])
from openstack_dashboard.test.test_plugins import panel_config from openstack_dashboard.utils import settings as util_settings HORIZON_CONFIG = copy.deepcopy(settings.HORIZON_CONFIG) INSTALLED_APPS = list(settings.INSTALLED_APPS) # NOTE: Ensure dashboards and default_dashboard are not included in # HORIZON_CONFIG to ensure warning messages from update_dashboards below. HORIZON_CONFIG.pop('dashboards', None) HORIZON_CONFIG.pop('default_dashboard', None) HORIZON_CONFIG.pop('js_files', None) HORIZON_CONFIG.pop('js_spec_files', None) HORIZON_CONFIG.pop('scss_files', None) util_settings.update_dashboards([panel_config,], HORIZON_CONFIG, INSTALLED_APPS) @override_settings(HORIZON_CONFIG=HORIZON_CONFIG, INSTALLED_APPS=INSTALLED_APPS) class PanelPluginTests(test.PluginTestCase): def test_add_panel(self): dashboard = horizon.get_dashboard("admin") panel_group = dashboard.get_panel_group('admin') # Check that the panel is in its configured dashboard. self.assertIn(plugin_panel.PluginPanel, [p.__class__ for p in dashboard.get_panels()]) # Check that the panel is in its configured panel group. self.assertIn(plugin_panel.PluginPanel, [p.__class__ for p in panel_group]) # Ensure that static resources are properly injected
SECRET_KEY = None LOCAL_PATH = None try: from local.local_settings import * # noqa except ImportError: logging.warning("No local_settings file found.") # Load the pluggable dashboard settings import openstack_dashboard.enabled import openstack_dashboard.local.enabled from openstack_dashboard.utils import settings INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable settings.update_dashboards([ openstack_dashboard.enabled, openstack_dashboard.local.enabled, ], HORIZON_CONFIG, INSTALLED_APPS) # Ensure that we always have a SECRET_KEY set, even when no local_settings.py # file is present. See local_settings.py.example for full documentation on the # horizon.utils.secret_key module and its use. if not SECRET_KEY: if not LOCAL_PATH: LOCAL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'local') from horizon.utils import secret_key SECRET_KEY = secret_key.generate_or_read_from_file(os.path.join(LOCAL_PATH, '.secret_key_store')) from openstack_dashboard import policy
def setUp(self): super(PanelGroupPluginTests, self).setUp() util_settings.update_dashboards([ openstack_dashboard.test.test_plugins.panel_group_config, ], HORIZON_CONFIG, INSTALLED_APPS)