mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
cI: Test color theme again (#7700)
* Adjust caching key to be numeric for user * Add strong usermodel to colortheme * switch to using user model everywhere for colortheme * re-enable ColorTheme tests * fix call * remove old migratin * fix directory discovery
This commit is contained in:
parent
0effb44402
commit
0f6551d70f
@ -2589,14 +2589,22 @@ class ColorTheme(models.Model):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_color_themes_choices(cls):
|
def get_color_themes_choices(cls):
|
||||||
"""Get all color themes from static folder."""
|
"""Get all color themes from static folder."""
|
||||||
if not django_settings.STATIC_COLOR_THEMES_DIR.exists():
|
color_theme_dir = (
|
||||||
logger.error('Theme directory does not exist')
|
django_settings.STATIC_COLOR_THEMES_DIR
|
||||||
|
if django_settings.STATIC_COLOR_THEMES_DIR.exists()
|
||||||
|
else django_settings.BASE_DIR.joinpath(
|
||||||
|
'InvenTree', 'static', 'css', 'color-themes'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not color_theme_dir.exists():
|
||||||
|
logger.error(f'Theme directory "{color_theme_dir}" does not exist')
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Get files list from css/color-themes/ folder
|
# Get files list from css/color-themes/ folder
|
||||||
files_list = []
|
files_list = []
|
||||||
|
|
||||||
for file in django_settings.STATIC_COLOR_THEMES_DIR.iterdir():
|
for file in color_theme_dir.iterdir():
|
||||||
files_list.append([file.stem, file.suffix])
|
files_list.append([file.stem, file.suffix])
|
||||||
|
|
||||||
# Get color themes choices (CSS sheets)
|
# Get color themes choices (CSS sheets)
|
||||||
|
@ -1199,20 +1199,10 @@ class ColorThemeTest(TestCase):
|
|||||||
def test_choices(self):
|
def test_choices(self):
|
||||||
"""Test that default choices are returned."""
|
"""Test that default choices are returned."""
|
||||||
result = ColorTheme.get_color_themes_choices()
|
result = ColorTheme.get_color_themes_choices()
|
||||||
|
|
||||||
# skip due to directories not being set up
|
|
||||||
if not result:
|
|
||||||
return # pragma: no cover
|
|
||||||
self.assertIn(('default', 'Default'), result)
|
self.assertIn(('default', 'Default'), result)
|
||||||
|
|
||||||
def test_valid_choice(self):
|
def test_valid_choice(self):
|
||||||
"""Check that is_valid_choice works correctly."""
|
"""Check that is_valid_choice works correctly."""
|
||||||
result = ColorTheme.get_color_themes_choices()
|
|
||||||
|
|
||||||
# skip due to directories not being set up
|
|
||||||
if not result:
|
|
||||||
return # pragma: no cover
|
|
||||||
|
|
||||||
# check wrong reference
|
# check wrong reference
|
||||||
self.assertFalse(ColorTheme.is_valid_choice('abcdd'))
|
self.assertFalse(ColorTheme.is_valid_choice('abcdd'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user