mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix: tests
This commit is contained in:
parent
05c8db8c8e
commit
2d0e194221
@ -352,24 +352,24 @@ class TestInvenTreeBarcode(InvenTreeAPITestCase):
|
||||
|
||||
def test_generation_inventree_json(self):
|
||||
"""Test JSON barcode generation."""
|
||||
item = stock.models.StockLocation.objects.get(pk=522)
|
||||
item = stock.models.StockLocation.objects.get(pk=5)
|
||||
data = self.generate('stocklocation', item.pk, expected_code=200).data
|
||||
self.assertEqual(data['barcode'], '{"location": 522}')
|
||||
self.assertEqual(data['barcode'], '{"stocklocation": 5}')
|
||||
|
||||
def test_generation_inventree_short(self):
|
||||
"""Test short barcode generation."""
|
||||
self.set_plugin_setting('INTERNAL_BARCODE_FORMAT', 'short')
|
||||
|
||||
item = stock.models.StockLocation.objects.get(pk=522)
|
||||
item = stock.models.StockLocation.objects.get(pk=5)
|
||||
|
||||
# test with default prefix
|
||||
data = self.generate('stocklocation', item.pk, expected_code=200).data
|
||||
self.assertEqual(data['barcode'], 'INV-SL522')
|
||||
self.assertEqual(data['barcode'], 'INV-SL5')
|
||||
|
||||
# test with custom prefix
|
||||
self.set_plugin_setting('SHORT_BARCODE_PREFIX', 'TEST')
|
||||
data = self.generate('stocklocation', item.pk, expected_code=200).data
|
||||
self.assertEqual(data['barcode'], 'TESTSL522')
|
||||
self.assertEqual(data['barcode'], 'TESTSL5')
|
||||
self.set_plugin_setting('SHORT_BARCODE_PREFIX', 'INV-')
|
||||
|
||||
self.set_internal_barcode_format('INTERNAL_BARCODE_FORMAT', 'json')
|
||||
|
@ -35,7 +35,7 @@ def qrcode(data, **kwargs):
|
||||
|
||||
Keyword Arguments:
|
||||
version: QR code version, (None to auto detect) (default = None)
|
||||
error_correction: Error correction level (L: 7%, M: 15%, Q: 25%, H: 30%) (default = 'Q')
|
||||
error_correction: Error correction level (L: 7%, M: 15%, Q: 25%, H: 30%) (default = 'M')
|
||||
box_size: pixel dimensions for one black square pixel in the QR code (default = 20)
|
||||
border: count white QR square pixels around the qr code, needed as padding (default = 1)
|
||||
optimize: data will be split into multiple chunks of at least this length using different modes (text, alphanumeric, binary) to optimize the QR code size. Set to `0` to disable. (default = 1)
|
||||
@ -59,7 +59,7 @@ def qrcode(data, **kwargs):
|
||||
'border': 1,
|
||||
'version': None,
|
||||
**kwargs,
|
||||
'error_correction': QR_ECL_LEVEL_MAP[kwargs.get('error_correction', 'Q')],
|
||||
'error_correction': QR_ECL_LEVEL_MAP[kwargs.get('error_correction', 'M')],
|
||||
})
|
||||
qr.add_data(data, optimize=optimize)
|
||||
qr.make(fit=False) # if version is None, it will automatically use fit=True
|
||||
|
Loading…
Reference in New Issue
Block a user