mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	test color theme
This commit is contained in:
		| @@ -7,7 +7,7 @@ from datetime import timedelta | |||||||
| from django.test import TestCase, Client | from django.test import TestCase, Client | ||||||
| from django.contrib.auth import get_user_model | from django.contrib.auth import get_user_model | ||||||
|  |  | ||||||
| from .models import InvenTreeSetting, WebhookEndpoint, WebhookMessage, NotificationEntry | from .models import InvenTreeSetting, WebhookEndpoint, WebhookMessage, NotificationEntry, ColorTheme | ||||||
| from .api import WebhookView | from .api import WebhookView | ||||||
|  |  | ||||||
| CONTENT_TYPE_JSON = 'application/json' | CONTENT_TYPE_JSON = 'application/json' | ||||||
| @@ -299,3 +299,26 @@ class LoadingTest(TestCase): | |||||||
|  |  | ||||||
|         # now it should be false again |         # now it should be false again | ||||||
|         self.assertFalse(common.models.InvenTreeSetting.get_setting('SERVER_RESTART_REQUIRED')) |         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)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user