mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
only raise if integrity error
This commit is contained in:
parent
b914888c20
commit
494c4ed03d
@ -7,7 +7,7 @@ import django.core.exceptions as django_exceptions
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.conf import settings
|
||||
# from django.db.utils import IntegrityError
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from djmoney.money import Money
|
||||
from djmoney.contrib.exchange.models import Rate, convert_money
|
||||
@ -455,11 +455,11 @@ class TestSettings(TestCase):
|
||||
self.assertEqual(user_count(), 1)
|
||||
|
||||
# enough set - duplicate entry
|
||||
# with self.assertRaises(IntegrityError):
|
||||
self.env.set('INVENTREE_ADMIN_USER', 'admin') # set username
|
||||
self.env.set('INVENTREE_ADMIN_EMAIL', 'info@example.com') # set email
|
||||
self.env.set('INVENTREE_ADMIN_PASSWORD', 'password123') # set password
|
||||
self.run_reload()
|
||||
with self.assertRaises(IntegrityError):
|
||||
self.env.set('INVENTREE_ADMIN_USER', 'admin') # set username
|
||||
self.env.set('INVENTREE_ADMIN_EMAIL', 'info@example.com') # set email
|
||||
self.env.set('INVENTREE_ADMIN_PASSWORD', 'password123') # set password
|
||||
self.run_reload()
|
||||
self.assertEqual(user_count(), 1)
|
||||
|
||||
# make sure to clean up
|
||||
|
@ -11,6 +11,7 @@ import pkgutil
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import AppRegistryNotReady
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
|
||||
# region logging / errors
|
||||
@ -86,7 +87,7 @@ def handle_error(error, do_raise: bool = True, do_log: bool = True, log_name: st
|
||||
|
||||
if do_raise:
|
||||
# do a straight raise if we are playing with enviroment variables at execution time, ignore the broken sample
|
||||
if settings.TESTING_ENV and package_name != 'integration.broken_sample':
|
||||
if settings.TESTING_ENV and package_name != 'integration.broken_sample' and isinstance(error, IntegrityError):
|
||||
raise error
|
||||
raise IntegrationPluginError(package_name, str(error))
|
||||
# endregion
|
||||
|
Loading…
Reference in New Issue
Block a user