fix label tests

This commit is contained in:
Matthias 2022-02-13 21:15:40 +01:00
parent b49d46af58
commit a6621a5327
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 16 additions and 7 deletions

View File

@ -35,9 +35,15 @@ class LabelConfig(AppConfig):
"""
if canAppAccessDatabase():
self.create_stock_item_labels()
self.create_stock_location_labels()
self.create_part_labels()
self.create_labels()
def create_labels(self):
"""
Create all default templates
"""
self.create_stock_item_labels()
self.create_stock_location_labels()
self.create_part_labels()
def create_stock_item_labels(self):
"""

View File

@ -7,6 +7,7 @@ import os
from django.test import TestCase
from django.conf import settings
from django.apps import apps
from django.core.exceptions import ValidationError
from InvenTree.helpers import validateFilterString
@ -17,8 +18,11 @@ from stock.models import StockItem
class LabelTest(TestCase):
# TODO - Implement this test properly. Looks like apps.py is not run first
def _test_default_labels(self):
def setUp(self) -> None:
# ensure the labels were created
apps.get_app_config('label').create_labels()
def test_default_labels(self):
"""
Test that the default label templates are copied across
"""
@ -31,8 +35,7 @@ class LabelTest(TestCase):
self.assertTrue(labels.count() > 0)
# TODO - Implement this test properly. Looks like apps.py is not run first
def _test_default_files(self):
def test_default_files(self):
"""
Test that label files exist in the MEDIA directory
"""