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 enabled
|
||||||
from openstack_dashboard import exceptions
|
from openstack_dashboard import exceptions
|
||||||
|
from openstack_dashboard import theme_settings
|
||||||
from openstack_dashboard.utils import settings as settings_utils
|
from openstack_dashboard.utils import settings as settings_utils
|
||||||
|
|
||||||
# this is used to protect from client XSS attacks, but it's worth
|
# this is used to protect from client XSS attacks, but it's worth
|
||||||
@ -60,14 +61,8 @@ AVAILABLE_THEMES = [
|
|||||||
'themes/material'
|
'themes/material'
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
AVAILABLE_THEMES, SELECTABLE_THEMES, DEFAULT_THEME = \
|
||||||
SELECTABLE_THEMES = [
|
theme_settings.get_available_themes(AVAILABLE_THEMES, 'default', None)
|
||||||
(
|
|
||||||
'default',
|
|
||||||
pgettext_lazy('Default style theme', 'Default'),
|
|
||||||
'themes/default'
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
# Theme Static Directory
|
# Theme Static Directory
|
||||||
THEME_COLLECTION_DIR = 'themes'
|
THEME_COLLECTION_DIR = 'themes'
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# 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.templatetags import themes
|
||||||
from openstack_dashboard.test import helpers as test
|
from openstack_dashboard.test import helpers as test
|
||||||
|
|
||||||
@ -23,6 +25,9 @@ class SelectableThemeTest(test.TestCase):
|
|||||||
# 'available' list
|
# 'available' list
|
||||||
self.assertEqual(selectable, available)
|
self.assertEqual(selectable, available)
|
||||||
|
|
||||||
|
@override_settings(SELECTABLE_THEMES=[
|
||||||
|
('default', 'Default', 'themes/default'),
|
||||||
|
])
|
||||||
def test_selectable_override(self):
|
def test_selectable_override(self):
|
||||||
selectable = themes.themes()
|
selectable = themes.themes()
|
||||||
available = themes.settings.AVAILABLE_THEMES
|
available = themes.settings.AVAILABLE_THEMES
|
||||||
|
Loading…
x
Reference in New Issue
Block a user