2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-03 13:58:47 +00:00

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 # Helper function to check for duplicated numbers
def add_sn(sn): def add_sn(sn):
if sn in numbers: if sn in numbers:
errors.append(_('Duplicate serial: {sn}').format(n=n)) errors.append(_('Duplicate serial: {sn}').format(sn=sn))
else: else:
numbers.append(sn) numbers.append(sn)
@ -504,9 +504,13 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
errors.append(_("Invalid group: {g}").format(g=group)) errors.append(_("Invalid group: {g}").format(g=group))
# At this point, we assume that the "group" is just a single serial value # 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: elif 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) add_sn(group)
# No valid input group detected # No valid input group detected

View File

@ -14,6 +14,8 @@ from django_q.monitor import Stat
from django.conf import settings from django.conf import settings
import InvenTree.ready
logger = logging.getLogger("inventree") logger = logging.getLogger("inventree")
@ -56,6 +58,12 @@ def is_email_configured():
configured = True configured = True
if InvenTree.ready.isInTestMode():
return False
if InvenTree.ready.isImportingData():
return False
if not settings.EMAIL_HOST: if not settings.EMAIL_HOST:
configured = False configured = False
@ -89,6 +97,14 @@ def check_system_health(**kwargs):
result = True 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 if not is_worker_running(**kwargs): # pragma: no cover
result = False result = False
logger.warning(_("Background worker check failed")) logger.warning(_("Background worker check failed"))