From 2d0e19422157ef9c2bf583fecbc44cf25626115e Mon Sep 17 00:00:00 2001 From: wolflu05 <76838159+wolflu05@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:25:37 +0200 Subject: [PATCH] fix: tests --- .../plugin/builtin/barcodes/test_inventree_barcode.py | 10 +++++----- src/backend/InvenTree/report/templatetags/barcode.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backend/InvenTree/plugin/builtin/barcodes/test_inventree_barcode.py b/src/backend/InvenTree/plugin/builtin/barcodes/test_inventree_barcode.py index 093541accf..da9301f496 100644 --- a/src/backend/InvenTree/plugin/builtin/barcodes/test_inventree_barcode.py +++ b/src/backend/InvenTree/plugin/builtin/barcodes/test_inventree_barcode.py @@ -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') diff --git a/src/backend/InvenTree/report/templatetags/barcode.py b/src/backend/InvenTree/report/templatetags/barcode.py index 0dbafbb9b8..e8f61c424f 100644 --- a/src/backend/InvenTree/report/templatetags/barcode.py +++ b/src/backend/InvenTree/report/templatetags/barcode.py @@ -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