mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
fix test transactions
This commit is contained in:
parent
3b1bfddd8b
commit
4e898d5eac
@ -6,6 +6,7 @@ from django.apps import AppConfig
|
||||
from django.core.exceptions import AppRegistryNotReady
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import transaction
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from InvenTree.ready import isInTestMode, canAppAccessDatabase
|
||||
@ -186,6 +187,7 @@ class InvenTreeConfig(AppConfig):
|
||||
# good to go -> create user
|
||||
user = get_user_model()
|
||||
try:
|
||||
with transaction.atomic():
|
||||
new_user = user.objects.create_user(add_user, add_email, add_password)
|
||||
logger.info(f'User {str(new_user)} was created!')
|
||||
except IntegrityError as _e:
|
||||
|
@ -453,6 +453,6 @@ class TestSettings(TestCase):
|
||||
self.env.set('INVENTREE_SET_USER', 'admin') # set username
|
||||
self.env.set('INVENTREE_SET_EMAIL', 'info@example.com') # set email
|
||||
self.env.set('INVENTREE_SET_PASSWORD', 'password123') # set password
|
||||
with self.assertRaises(IntegrityError, IntegrationPluginError):
|
||||
with self.assertRaises(IntegrationPluginError):
|
||||
self.run_reload()
|
||||
self.assertEqual(user_count(), 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user