Add test for ColorTheme

This commit is contained in:
Matthias 2022-05-07 23:12:15 +02:00
parent 52bae1feef
commit 13854998ea
No known key found for this signature in database
GPG Key ID: AB6D0E6C4CB65093

View File

@ -12,7 +12,7 @@ from InvenTree.api_tester import InvenTreeAPITestCase
from InvenTree.helpers import str2bool
from plugin.models import NotificationUserSetting
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'
@ -561,3 +561,24 @@ 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):
result = ColorTheme.get_color_themes_choices()
self.assertIn(('default', 'Default'), result)
def test_valid_choice(self):
# 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))