Fixes for unit tests (#4441)

(cherry picked from commit 0bbba26e6331b05696cadfb21e36617de62d999c)
This commit is contained in:
Oliver 2023-03-03 15:53:31 +11:00 committed by GitHub
parent 31f4045465
commit 2d7f9e3a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -831,15 +831,15 @@ class TestSettings(helpers.InvenTreeTestCase):
self.assertEqual(config.get_setting(TEST_ENV_NAME, None), '321')
# test typecasting to dict - None should be mapped to empty dict
self.assertEqual(config.get_setting(TEST_ENV_NAME, None, None), {})
self.assertEqual(config.get_setting(TEST_ENV_NAME, None, None, typecast=dict), {})
# test typecasting to dict - valid JSON string should be mapped to corresponding dict
with self.in_env_context({TEST_ENV_NAME: '{"a": 1}'}):
self.assertEqual(config.get_setting(TEST_ENV_NAME, None), {"a": 1})
self.assertEqual(config.get_setting(TEST_ENV_NAME, None, typecast=dict), {"a": 1})
# test typecasting to dict - invalid JSON string should be mapped to empty dict
with self.in_env_context({TEST_ENV_NAME: "{'a': 1}"}):
self.assertEqual(config.get_setting(TEST_ENV_NAME, None), {})
self.assertEqual(config.get_setting(TEST_ENV_NAME, None, typecast=dict), {})
class TestInstanceName(helpers.InvenTreeTestCase):