fix: tests

This commit is contained in:
Lukas 2024-07-19 23:29:05 +02:00 committed by GitHub
parent aebf7ab147
commit 3a2d46ff72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -340,14 +340,13 @@ class TestInvenTreeBarcode(InvenTreeAPITestCase):
self.assertEqual(response.data['part']['pk'], 5)
# Scan a SupplierPart instance with custom prefix
for prefix in ['TEST', '']:
self.set_plugin_setting('SHORT_BARCODE_PREFIX', prefix)
response = self.scan({'barcode': f'{prefix}SP1'}, expected_code=200)
self.assertEqual(response.data['supplierpart']['pk'], 1)
self.assertEqual(response.data['plugin'], 'InvenTreeBarcode')
self.assertIn('success', response.data)
self.assertIn('barcode_data', response.data)
self.assertIn('barcode_hash', response.data)
self.set_plugin_setting('SHORT_BARCODE_PREFIX', 'TEST')
response = self.scan({'barcode': 'TESTSP1'}, expected_code=200)
self.assertEqual(response.data['supplierpart']['pk'], 1)
self.assertEqual(response.data['plugin'], 'InvenTreeBarcode')
self.assertIn('success', response.data)
self.assertIn('barcode_data', response.data)
self.assertIn('barcode_hash', response.data)
self.set_plugin_setting('SHORT_BARCODE_PREFIX', 'INV-')
@ -368,10 +367,9 @@ class TestInvenTreeBarcode(InvenTreeAPITestCase):
self.assertEqual(data['barcode'], 'INV-SL5')
# test generation with custom prefix
for prefix in ['TEST', '']:
self.set_plugin_setting('SHORT_BARCODE_PREFIX', prefix)
data = self.generate('stocklocation', item.pk, expected_code=200).data
self.assertEqual(data['barcode'], f'{prefix}SL5')
self.set_plugin_setting('SHORT_BARCODE_PREFIX', 'TEST')
data = self.generate('stocklocation', item.pk, expected_code=200).data
self.assertEqual(data['barcode'], 'TESTSL5')
self.set_plugin_setting('SHORT_BARCODE_PREFIX', 'INV-')
self.set_plugin_setting('INTERNAL_BARCODE_FORMAT', 'json')