From a6621a5327025ce84e8a72420024e715a455073c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 13 Feb 2022 21:15:40 +0100 Subject: [PATCH] fix label tests --- InvenTree/label/apps.py | 12 +++++++++--- InvenTree/label/tests.py | 11 +++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/InvenTree/label/apps.py b/InvenTree/label/apps.py index 2556e11bca..2954d8a407 100644 --- a/InvenTree/label/apps.py +++ b/InvenTree/label/apps.py @@ -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): """ diff --git a/InvenTree/label/tests.py b/InvenTree/label/tests.py index aaf93fd0a0..1e7e7994ae 100644 --- a/InvenTree/label/tests.py +++ b/InvenTree/label/tests.py @@ -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 """