mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Stock: More unit tests
- Add some more tests (would have caught a bug that was there already, darn it)
This commit is contained in:
parent
8615cad711
commit
59e7474f75
@ -81,6 +81,59 @@ class StockItemTest(StockAPITestCase):
|
|||||||
response = self.client.get(self.list_url, format='json')
|
response = self.client.get(self.list_url, format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
def test_stock_item_create(self):
|
||||||
|
"""
|
||||||
|
Test creation of a StockItem via the API
|
||||||
|
"""
|
||||||
|
|
||||||
|
# POST with an empty part reference
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
self.list_url,
|
||||||
|
data={
|
||||||
|
'quantity': 10,
|
||||||
|
'location': 1
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(response, 'This field is required', status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
# POST with an invalid part reference
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
self.list_url,
|
||||||
|
data={
|
||||||
|
'quantity': 10,
|
||||||
|
'location': 1,
|
||||||
|
'part': 10000000,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(response, 'does not exist', status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
# POST without quantity
|
||||||
|
response = self.client.post(
|
||||||
|
self.list_url,
|
||||||
|
data={
|
||||||
|
'part': 1,
|
||||||
|
'location': 1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertContains(response, 'This field is required', status_code=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
# POST with quantity and part and location
|
||||||
|
response = self.client.post(
|
||||||
|
self.list_url,
|
||||||
|
data={
|
||||||
|
'part': 1,
|
||||||
|
'location': 1,
|
||||||
|
'quantity': 10,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
|
||||||
class StocktakeTest(StockAPITestCase):
|
class StocktakeTest(StockAPITestCase):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user