test instance name

This commit is contained in:
Matthias 2022-03-13 20:38:02 +01:00
parent 44fb356a3b
commit 00637f4b6c
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -1,4 +1,5 @@
import imp
import json import json
from test.support import EnvironmentVarGuard from test.support import EnvironmentVarGuard
@ -25,6 +26,7 @@ import InvenTree.tasks
from stock.models import StockLocation from stock.models import StockLocation
from common.settings import currency_codes from common.settings import currency_codes
from common.models import InvenTreeSetting
class ValidatorTest(TestCase): class ValidatorTest(TestCase):
@ -482,3 +484,26 @@ class TestSettings(TestCase):
with self.env: with self.env:
self.env.set(TEST_ENV_NAME, '321') self.env.set(TEST_ENV_NAME, '321')
self.assertEqual(get_setting(TEST_ENV_NAME, None), '321') self.assertEqual(get_setting(TEST_ENV_NAME, None), '321')
class TestInstanceName(TestCase):
"""
Unit tests for instance name
"""
def setUp(self):
# Create a user for auth
user = get_user_model()
self.user = user.objects.create_superuser('testuser', 'test@testing.com', 'password')
self.client.login(username='testuser', password='password')
def test_instance_name(self):
# default setting
self.assertEqual(version.inventreeInstanceTitle(), 'InvenTree')
# set up required setting
InvenTreeSetting.set_setting("INVENTREE_INSTANCE_TITLE", True, self.user)
InvenTreeSetting.set_setting("INVENTREE_INSTANCE", "Testing title", self.user)
self.assertEqual(version.inventreeInstanceTitle(), 'Testing title')