Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wolflu05 authored Jul 19, 2024
1 parent aebf7ab commit 3a2d46f
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,13 @@ def test_scan_inventree_short(self):
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-')

Expand All @@ -368,10 +367,9 @@ def test_generation_inventree_short(self):
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')

0 comments on commit 3a2d46f

Please sign in to comment.