mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 03:56:43 +00:00
add test for rendering label
This commit is contained in:
parent
a65d747501
commit
f620491517
@ -8,17 +8,27 @@ import os
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
from django.urls import reverse
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from InvenTree.helpers import validateFilterString
|
from InvenTree.helpers import validateFilterString
|
||||||
|
from InvenTree.api_tester import InvenTreeAPITestCase
|
||||||
|
|
||||||
from .models import StockItemLabel, StockLocationLabel
|
from .models import StockItemLabel, StockLocationLabel, PartLabel
|
||||||
from stock.models import StockItem
|
from stock.models import StockItem
|
||||||
|
|
||||||
|
|
||||||
class LabelTest(TestCase):
|
class LabelTest(InvenTreeAPITestCase):
|
||||||
|
|
||||||
|
fixtures = [
|
||||||
|
'category',
|
||||||
|
'part',
|
||||||
|
'location',
|
||||||
|
'stock'
|
||||||
|
]
|
||||||
|
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
|
super().setUp()
|
||||||
# ensure the labels were created
|
# ensure the labels were created
|
||||||
apps.get_app_config('label').create_labels()
|
apps.get_app_config('label').create_labels()
|
||||||
|
|
||||||
@ -77,3 +87,13 @@ class LabelTest(TestCase):
|
|||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
validateFilterString(bad_filter_string, model=StockItem)
|
validateFilterString(bad_filter_string, model=StockItem)
|
||||||
|
|
||||||
|
def test_label_rendering(self):
|
||||||
|
"""Test label rendering"""
|
||||||
|
|
||||||
|
labels = [PartLabel.objects.first(), ]
|
||||||
|
part = PartLabel.objects.first()
|
||||||
|
|
||||||
|
for label in labels:
|
||||||
|
url = reverse('api-part-label-print', kwargs={'pk': label.pk})
|
||||||
|
self.get(f'{url}?parts={part.pk}', expected_code=200)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user