mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +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.core.exceptions import ValidationError
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
# from django.db.utils import IntegrityError
|
from django.db.utils import IntegrityError
|
||||||
|
|
||||||
from djmoney.money import Money
|
from djmoney.money import Money
|
||||||
from djmoney.contrib.exchange.models import Rate, convert_money
|
from djmoney.contrib.exchange.models import Rate, convert_money
|
||||||
@ -455,11 +455,11 @@ class TestSettings(TestCase):
|
|||||||
self.assertEqual(user_count(), 1)
|
self.assertEqual(user_count(), 1)
|
||||||
|
|
||||||
# enough set - duplicate entry
|
# enough set - duplicate entry
|
||||||
# with self.assertRaises(IntegrityError):
|
with self.assertRaises(IntegrityError):
|
||||||
self.env.set('INVENTREE_ADMIN_USER', 'admin') # set username
|
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_EMAIL', 'info@example.com') # set email
|
||||||
self.env.set('INVENTREE_ADMIN_PASSWORD', 'password123') # set password
|
self.env.set('INVENTREE_ADMIN_PASSWORD', 'password123') # set password
|
||||||
self.run_reload()
|
self.run_reload()
|
||||||
self.assertEqual(user_count(), 1)
|
self.assertEqual(user_count(), 1)
|
||||||
|
|
||||||
# make sure to clean up
|
# make sure to clean up
|
||||||
|
@ -11,6 +11,7 @@ import pkgutil
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import AppRegistryNotReady
|
from django.core.exceptions import AppRegistryNotReady
|
||||||
|
from django.db.utils import IntegrityError
|
||||||
|
|
||||||
|
|
||||||
# region logging / errors
|
# 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:
|
if do_raise:
|
||||||
# do a straight raise if we are playing with enviroment variables at execution time, ignore the broken sample
|
# 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 error
|
||||||
raise IntegrationPluginError(package_name, str(error))
|
raise IntegrationPluginError(package_name, str(error))
|
||||||
# endregion
|
# endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user