Do not load openstack_dashboard.settings in unit tests
The previous behavior depends on different values for SELECTABLE_THEMES and it seems this is the reason that test_themes imported openstack_dashboard.settings. If we override a value in django.conf.settings, we can use override_settings decorator. This commit uses it and we can now avoid importing openstack_dashboard.settings in UT. Change-Id: Id1b7b7e431b86e725ad897613ca38f423a67e52d Closes-Bug: #1809842
This commit is contained in:
parent
87e2cf67fa
commit
372b75c222
@ -21,6 +21,7 @@ from horizon.utils import secret_key
|
||||
|
||||
from openstack_dashboard import enabled
|
||||
from openstack_dashboard import exceptions
|
||||
from openstack_dashboard import theme_settings
|
||||
from openstack_dashboard.utils import settings as settings_utils
|
||||
|
||||
# this is used to protect from client XSS attacks, but it's worth
|
||||
@ -60,14 +61,8 @@ AVAILABLE_THEMES = [
|
||||
'themes/material'
|
||||
),
|
||||
]
|
||||
|
||||
SELECTABLE_THEMES = [
|
||||
(
|
||||
'default',
|
||||
pgettext_lazy('Default style theme', 'Default'),
|
||||
'themes/default'
|
||||
),
|
||||
]
|
||||
AVAILABLE_THEMES, SELECTABLE_THEMES, DEFAULT_THEME = \
|
||||
theme_settings.get_available_themes(AVAILABLE_THEMES, 'default', None)
|
||||
|
||||
# Theme Static Directory
|
||||
THEME_COLLECTION_DIR = 'themes'
|
||||
|
@ -10,7 +10,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack_dashboard import settings
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from openstack_dashboard.templatetags import themes
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
@ -23,6 +25,9 @@ class SelectableThemeTest(test.TestCase):
|
||||
# 'available' list
|
||||
self.assertEqual(selectable, available)
|
||||
|
||||
@override_settings(SELECTABLE_THEMES=[
|
||||
('default', 'Default', 'themes/default'),
|
||||
])
|
||||
def test_selectable_override(self):
|
||||
selectable = themes.themes()
|
||||
available = themes.settings.AVAILABLE_THEMES
|
||||
|
Loading…
Reference in New Issue
Block a user