Use django.conf.settings instead of local_settings

The default and preferred way of modifying the settings of Horizon
plugin is to add a configuration file to
openstack_dashboard/local/local_settings.d/ directory [1]. For that to
work we should use the settings from django.conf.settings and not from
monitoring.config.local_settings.

[1] https://docs.openstack.org/horizon/latest/configuration/settings.html

Story: 2006556
Task: 36644

Change-Id: I5cd66954ffb1169f3149cd6f705593efe3a15b13
This commit is contained in:
Witek Bedyk 2019-09-16 11:20:45 +02:00
parent f0231ab00f
commit 855a1f2fc5
3 changed files with 10 additions and 4 deletions

View File

@ -19,5 +19,5 @@ from django.core.management import execute_from_command_line
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"openstack_dashboard.settings") "monitoring.test.settings")
execute_from_command_line(sys.argv) execute_from_command_line(sys.argv)

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
from django.test import RequestFactory from django.test import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse from django.urls import reverse
from monitoring.overview import constants from monitoring.overview import constants
@ -26,6 +27,12 @@ INDEX_URL = reverse(
class OverviewTest(helpers.TestCase): class OverviewTest(helpers.TestCase):
@override_settings(DASHBOARDS=[],
KIBANA_POLICY_SCOPE='monitoring',
KIBANA_POLICY_RULE='monitoring:kibana_access',
ENABLE_LOG_MANAGEMENT_BUTTON=False,
ENABLE_EVENT_MANAGEMENT_BUTTON=False,
SHOW_GRAFANA_HOME=True)
def test_index_get(self): def test_index_get(self):
res = self.client.get(INDEX_URL) res = self.client.get(INDEX_URL)
self.assertTemplateUsed( self.assertTemplateUsed(

View File

@ -17,6 +17,7 @@ import copy
import json import json
import logging import logging
from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django import http from django import http
from django.http import HttpResponse from django.http import HttpResponse
@ -25,16 +26,14 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views import generic from django.views import generic
from django.views.generic import TemplateView from django.views.generic import TemplateView
from horizon import exceptions
from openstack_auth import utils as auth_utils from openstack_auth import utils as auth_utils
from openstack_dashboard import policy from openstack_dashboard import policy
import six import six
from six.moves import urllib from six.moves import urllib
from horizon import exceptions
from monitoring.alarms import tables as alarm_tables from monitoring.alarms import tables as alarm_tables
from monitoring import api from monitoring import api
from monitoring.config import local_settings as settings
from monitoring.overview import constants from monitoring.overview import constants
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)