From 235954af187d774f26d33797c1e05254bc7f2abd Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 10 May 2022 22:08:23 +1000 Subject: [PATCH] Add unit test for invalid item --- InvenTree/barcodes/tests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/InvenTree/barcodes/tests.py b/InvenTree/barcodes/tests.py index 18d4e77d20..73bf066fb0 100644 --- a/InvenTree/barcodes/tests.py +++ b/InvenTree/barcodes/tests.py @@ -106,6 +106,23 @@ class BarcodeAPITest(APITestCase): self.assertIn('barcode_data', response.data) self.assertEqual(response.data['stockitem']['pk'], 1) + def test_invalid_item(self): + """Test response for invalid stock item""" + + response = self.client.post( + self.scan_url, + { + 'barcode': { + 'stockitem': 999999999, + } + }, + format='json' + ) + + self.assertEqual(response.status_code, 400) + + self.assertEqual(response.data['stockitem'], 'Stock item does not exist') + def test_find_location(self): """ Test that we can lookup a stock location based on ID