mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
Merge pull request #2991 from matmair/not-working-tests
Static test fixes
This commit is contained in:
@ -1722,6 +1722,9 @@ class ColorTheme(models.Model):
|
||||
@classmethod
|
||||
def get_color_themes_choices(cls):
|
||||
""" Get all color themes from static folder """
|
||||
if settings.TESTING and not os.path.exists(settings.STATIC_COLOR_THEMES_DIR):
|
||||
logger.error('Theme directory does not exsist')
|
||||
return []
|
||||
|
||||
# Get files list from css/color-themes/ folder
|
||||
files_list = []
|
||||
|
@ -12,7 +12,7 @@ from InvenTree.helpers import str2bool
|
||||
from plugin.models import NotificationUserSetting, PluginConfig
|
||||
from plugin import registry
|
||||
|
||||
from .models import InvenTreeSetting, InvenTreeUserSetting, WebhookEndpoint, WebhookMessage, NotificationEntry
|
||||
from .models import InvenTreeSetting, InvenTreeUserSetting, WebhookEndpoint, WebhookMessage, NotificationEntry, ColorTheme
|
||||
from .api import WebhookView
|
||||
|
||||
CONTENT_TYPE_JSON = 'application/json'
|
||||
@ -716,3 +716,35 @@ class LoadingTest(TestCase):
|
||||
|
||||
# now it should be false again
|
||||
self.assertFalse(common.models.InvenTreeSetting.get_setting('SERVER_RESTART_REQUIRED'))
|
||||
|
||||
|
||||
class ColorThemeTest(TestCase):
|
||||
"""Tests for ColorTheme"""
|
||||
|
||||
def test_choices(self):
|
||||
"""Test that default choices are returned"""
|
||||
result = ColorTheme.get_color_themes_choices()
|
||||
|
||||
# skip
|
||||
if not result:
|
||||
return
|
||||
self.assertIn(('default', 'Default'), result)
|
||||
|
||||
def test_valid_choice(self):
|
||||
"""Check that is_valid_choice works correctly"""
|
||||
result = ColorTheme.get_color_themes_choices()
|
||||
|
||||
# skip
|
||||
if not result:
|
||||
return
|
||||
|
||||
# check wrong reference
|
||||
self.assertFalse(ColorTheme.is_valid_choice('abcdd'))
|
||||
|
||||
# create themes
|
||||
aa = ColorTheme.objects.create(user='aa', name='testname')
|
||||
ab = ColorTheme.objects.create(user='ab', name='darker')
|
||||
|
||||
# check valid theme
|
||||
self.assertFalse(ColorTheme.is_valid_choice(aa))
|
||||
self.assertTrue(ColorTheme.is_valid_choice(ab))
|
||||
|
Reference in New Issue
Block a user