mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
barcode / InvenTreePugin test errors
This commit is contained in:
parent
3a2b52ae53
commit
a4737a1a2f
@ -214,3 +214,48 @@ class BarcodeAPITest(APITestCase):
|
|||||||
|
|
||||||
self.assertIn('error', data)
|
self.assertIn('error', data)
|
||||||
self.assertNotIn('success', data)
|
self.assertNotIn('success', data)
|
||||||
|
|
||||||
|
|
||||||
|
class TestInvenTreeBarcode(APITestCase):
|
||||||
|
|
||||||
|
fixtures = [
|
||||||
|
'category',
|
||||||
|
'part',
|
||||||
|
'location',
|
||||||
|
'stock'
|
||||||
|
]
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# Create a user for auth
|
||||||
|
user = get_user_model()
|
||||||
|
user.objects.create_user('testuser', 'test@testing.com', 'password')
|
||||||
|
|
||||||
|
self.client.login(username='testuser', password='password')
|
||||||
|
|
||||||
|
def test_errors(self):
|
||||||
|
"""
|
||||||
|
Test that a barcode can be associated with a StockItem
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_assert_error(barcode_data):
|
||||||
|
response = self.client.post(
|
||||||
|
reverse('api-barcode-link'), format='json',
|
||||||
|
data={
|
||||||
|
'barcode': barcode_data,
|
||||||
|
'stockitem': 522
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
self.assertIn('error', response.data)
|
||||||
|
|
||||||
|
# test with already existing stock
|
||||||
|
test_assert_error('{"stockitem": 522}')
|
||||||
|
|
||||||
|
# test with already existing stock location
|
||||||
|
test_assert_error('{"stocklocation": 7}')
|
||||||
|
|
||||||
|
# test with already existing part location
|
||||||
|
test_assert_error('{"part": 10004}')
|
||||||
|
|
||||||
|
# test with hash
|
||||||
|
test_assert_error('{"blbla": 10004}')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user