mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Unit test fixes
This commit is contained in:
parent
2d412e2be1
commit
03f7baf87f
@ -267,7 +267,7 @@ def WrapWithQuotes(text, quote='"'):
|
||||
return text
|
||||
|
||||
|
||||
def MakeBarcode(object_name, object_pk, object_data, **kwargs):
|
||||
def MakeBarcode(object_name, object_pk, object_data={}, **kwargs):
|
||||
""" Generate a string for a barcode. Adds some global InvenTree parameters.
|
||||
|
||||
Args:
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
import json
|
||||
|
||||
from django.test import TestCase
|
||||
import django.core.exceptions as django_exceptions
|
||||
from django.core.exceptions import ValidationError
|
||||
@ -134,7 +136,7 @@ class TestIncrement(TestCase):
|
||||
class TestMakeBarcode(TestCase):
|
||||
""" Tests for barcode string creation """
|
||||
|
||||
def test_barcode(self):
|
||||
def test_barcode_extended(self):
|
||||
|
||||
bc = helpers.MakeBarcode(
|
||||
"part",
|
||||
@ -142,13 +144,30 @@ class TestMakeBarcode(TestCase):
|
||||
{
|
||||
"id": 3,
|
||||
"url": "www.google.com",
|
||||
}
|
||||
},
|
||||
brief=False
|
||||
)
|
||||
|
||||
self.assertIn('part', bc)
|
||||
self.assertIn('tool', bc)
|
||||
self.assertIn('"tool": "InvenTree"', bc)
|
||||
|
||||
data = json.loads(bc)
|
||||
|
||||
self.assertEqual(data['part']['id'], 3)
|
||||
self.assertEqual(data['part']['url'], 'www.google.com')
|
||||
|
||||
def test_barcode_brief(self):
|
||||
|
||||
bc = helpers.MakeBarcode(
|
||||
"stockitem",
|
||||
7,
|
||||
)
|
||||
|
||||
data = json.loads(bc)
|
||||
self.assertEqual(len(data), 1)
|
||||
self.assertEqual(data['stockitem'], 7)
|
||||
|
||||
|
||||
class TestDownloadFile(TestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user