2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

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 import subprocess
from common.models import InvenTreeSetting from common.models import InvenTreeSetting
INVENTREE_SW_VERSION = "0.0.10" INVENTREE_SW_VERSION = "0.0.10"
def inventreeInstanceName(): def inventreeInstanceName():
""" Returns the InstanceName settings for the current database """ """ Returns the InstanceName settings for the current database """
return InvenTreeSetting.get_setting("InstanceName", "") return InvenTreeSetting.get_setting("InstanceName", "")

View File

@ -61,16 +61,20 @@ class CommonConfig(AppConfig):
# See note above # See note above
from .models import InvenTreeSetting 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( name = InvenTreeSetting(
key="InstanceName", key="InstanceName",
value=val, value=val,
description="Instance name for this InvenTree database installation." 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 # Generated by Django 2.2.10 on 2020-04-04 12:38
from django.db import migrations from django.db import migrations
from django.db.utils import OperationalError from django.db.utils import OperationalError, ProgrammingError
from part.models import Part from part.models import Part
from stdimage.utils import render_variations from stdimage.utils import render_variations
@ -17,8 +17,9 @@ def create_thumbnails(apps, schema_editor):
# Render thumbnail for each existing Part # Render thumbnail for each existing Part
if part.image: if part.image:
part.image.render_variations() part.image.render_variations()
except OperationalError: except (OperationalError, ProgrammingError):
print("Error - could not generate Part thumbnails") # Migrations have not yet been applied - table does not exist
print("Could not generate Part thumbnails")
class Migration(migrations.Migration): class Migration(migrations.Migration):