Fix import error

This commit is contained in:
Oliver Walters 2021-03-15 09:34:32 +11:00
parent 24823adc6d
commit c1aed51de1
2 changed files with 13 additions and 2 deletions

View File

@ -45,6 +45,8 @@ def get_setting(environment_var, backup_val, default_value=None):
return default_value return default_value
# Determine if we are running in "test" mode e.g. "manage.py test"
TESTING = 'test' in sys.argv
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -336,7 +338,7 @@ DATABASES = {}
When running unit tests, enforce usage of sqlite3 database, When running unit tests, enforce usage of sqlite3 database,
so that the tests can be run in RAM without any setup requirements so that the tests can be run in RAM without any setup requirements
""" """
if 'test' in sys.argv: if TESTING:
logger.info('InvenTree: Running tests - Using sqlite3 memory database') logger.info('InvenTree: Running tests - Using sqlite3 memory database')
DATABASES['default'] = { DATABASES['default'] = {
# Ensure sqlite3 backend is being used # Ensure sqlite3 backend is being used
@ -479,7 +481,10 @@ USE_I18N = True
USE_L10N = True USE_L10N = True
USE_TZ = True # Do not use native timezone support in "test" mode
# It generates a *lot* of cruft in the logs
if not TESTING:
USE_TZ = True
DATE_INPUT_FORMATS = [ DATE_INPUT_FORMATS = [
"%Y-%m-%d", "%Y-%m-%d",

View File

@ -75,6 +75,12 @@ def delete_successful_tasks():
which are more than a month old. which are more than a month old.
""" """
try:
from django_q.models import Success
logger.warning("Could not perform 'delete_successful_tasks' - App registry not ready")
except AppRegistryNotReady:
return
threshold = datetime.now() - timedelta(days=30) threshold = datetime.now() - timedelta(days=30)
results = Success.objects.filter( results = Success.objects.filter(