mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
add special env testing flag
This commit is contained in:
parent
737d397705
commit
12c4296261
@ -31,7 +31,7 @@ class InvenTreeConfig(AppConfig):
|
||||
if not isInTestMode():
|
||||
self.update_exchange_rates()
|
||||
|
||||
if canAppAccessDatabase() or settings.TESTING:
|
||||
if canAppAccessDatabase() or settings.TESTING_ENV:
|
||||
self.add_user_on_startup()
|
||||
|
||||
def remove_obsolete_tasks(self):
|
||||
@ -192,7 +192,7 @@ class InvenTreeConfig(AppConfig):
|
||||
logger.info(f'User {str(new_user)} was created!')
|
||||
except IntegrityError as _e:
|
||||
logger.warning(f'The user "{add_user}" could not be created due to the following error:\n{str(_e)}')
|
||||
if settings.TESTING:
|
||||
if settings.TESTING_ENV:
|
||||
raise _e
|
||||
|
||||
# do not try again
|
||||
|
@ -37,6 +37,7 @@ def _is_true(x):
|
||||
|
||||
# Determine if we are running in "test" mode e.g. "manage.py test"
|
||||
TESTING = 'test' in sys.argv
|
||||
TESTING_ENV = False
|
||||
|
||||
# New requirement for django 3.2+
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
@ -432,6 +432,8 @@ class TestSettings(TestCase):
|
||||
def test_set_user_to_few(self):
|
||||
# add shortcut
|
||||
user_count = self.user_mdl.objects.count
|
||||
# enable testing mode
|
||||
settings.TESTING_ENV = True
|
||||
|
||||
# nothing set
|
||||
self.assertEqual(user_count(), 0)
|
||||
@ -455,3 +457,6 @@ class TestSettings(TestCase):
|
||||
with self.assertRaises(IntegrationPluginError):
|
||||
self.run_reload()
|
||||
self.assertEqual(user_count(), 1)
|
||||
|
||||
# make sure to clean up
|
||||
settings.TESTING_ENV = False
|
||||
|
Loading…
Reference in New Issue
Block a user