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
|
||||
def get_color_themes_choices(cls):
|
||||
"""Get all color themes from static folder."""
|
||||
if not django_settings.STATIC_COLOR_THEMES_DIR.exists():
|
||||
logger.error('Theme directory does not exist')
|
||||
color_theme_dir = (
|
||||
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 []
|
||||
|
||||
# Get files list from css/color-themes/ folder
|
||||
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])
|
||||
|
||||
# Get color themes choices (CSS sheets)
|
||||
|
@ -1199,20 +1199,10 @@ class ColorThemeTest(TestCase):
|
||||
def test_choices(self):
|
||||
"""Test that default choices are returned."""
|
||||
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)
|
||||
|
||||
def test_valid_choice(self):
|
||||
"""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
|
||||
self.assertFalse(ColorTheme.is_valid_choice('abcdd'))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user