fixes for unit testing

This commit is contained in:
Oliver Walters 2020-04-06 21:01:24 +10:00
parent 0840cebd57
commit 3eb585df27
3 changed files with 18 additions and 13 deletions

View File

@ -5,9 +5,9 @@ Provides information on the current InvenTree version
import subprocess
from common.models import InvenTreeSetting
INVENTREE_SW_VERSION = "0.0.10"
def inventreeInstanceName():
""" Returns the InstanceName settings for the current database """
return InvenTreeSetting.get_setting("InstanceName", "")

View File

@ -61,16 +61,20 @@ class CommonConfig(AppConfig):
# See note above
from .models import InvenTreeSetting
if not InvenTreeSetting.objects.filter(key='InstanceName').exists():
try:
if not InvenTreeSetting.objects.filter(key='InstanceName').exists():
val = uuid.uuid4().hex
val = uuid.uuid4().hex
print("No 'InstanceName' found - generating random name '{n}'".format(n=val))
print("No 'InstanceName' found - generating random name '{n}'".format(n=val))
name = InvenTreeSetting(
key="InstanceName",
value=val,
description="Instance name for this InvenTree database installation."
)
name = InvenTreeSetting(
key="InstanceName",
value=val,
description="Instance name for this InvenTree database installation."
)
name.save()
name.save()
except (OperationalError, ProgrammingError):
# Migrations have not yet been applied - table does not exist
pass

View File

@ -1,7 +1,7 @@
# Generated by Django 2.2.10 on 2020-04-04 12:38
from django.db import migrations
from django.db.utils import OperationalError
from django.db.utils import OperationalError, ProgrammingError
from part.models import Part
from stdimage.utils import render_variations
@ -17,8 +17,9 @@ def create_thumbnails(apps, schema_editor):
# Render thumbnail for each existing Part
if part.image:
part.image.render_variations()
except OperationalError:
print("Error - could not generate Part thumbnails")
except (OperationalError, ProgrammingError):
# Migrations have not yet been applied - table does not exist
print("Could not generate Part thumbnails")
class Migration(migrations.Migration):