Fixes for unit tests

- Prioritize "integer" values when extracting serial numbers
This commit is contained in:
Oliver 2022-03-01 00:37:27 +11:00
parent 7ad9f8852e
commit 63d052e1ca
2 changed files with 23 additions and 3 deletions

View File

@ -439,7 +439,7 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
# Helper function to check for duplicated numbers
def add_sn(sn):
if sn in numbers:
errors.append(_('Duplicate serial: {sn}').format(n=n))
errors.append(_('Duplicate serial: {sn}').format(sn=sn))
else:
numbers.append(sn)
@ -504,10 +504,14 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
errors.append(_("Invalid group: {g}").format(g=group))
# At this point, we assume that the "group" is just a single serial value
# Note: At this point it is treated only as a string
elif group:
add_sn(group)
try:
# First attempt to add as an integer value
add_sn(int(group))
except (ValueError):
# As a backup, add as a string value
add_sn(group)
# No valid input group detected
else:

View File

@ -14,6 +14,8 @@ from django_q.monitor import Stat
from django.conf import settings
import InvenTree.ready
logger = logging.getLogger("inventree")
@ -56,6 +58,12 @@ def is_email_configured():
configured = True
if InvenTree.ready.isInTestMode():
return False
if InvenTree.ready.isImportingData():
return False
if not settings.EMAIL_HOST:
configured = False
@ -89,6 +97,14 @@ def check_system_health(**kwargs):
result = True
if InvenTree.ready.isInTestMode():
# Do not perform further checks if we are running unit tests
return False
if InvenTree.ready.isImportingData():
# Do not perform further checks if we are importing data
return False
if not is_worker_running(**kwargs): # pragma: no cover
result = False
logger.warning(_("Background worker check failed"))