mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-23 09:35:30 +00:00
Fixes for stock api unit tests
- Remove old unit tests - Require quantity when creating a new stock item
This commit is contained in:
@@ -60,70 +60,6 @@ class StockListTest(StockViewTestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class StockItemTest(StockViewTestCase):
|
||||
"""" Tests for StockItem views """
|
||||
|
||||
def test_qr_code(self):
|
||||
# QR code for a valid item
|
||||
response = self.client.get(reverse('stock-item-qr', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# QR code for an invalid item
|
||||
response = self.client.get(reverse('stock-item-qr', args=(9999,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_create_item(self):
|
||||
"""
|
||||
Test creation of StockItem
|
||||
"""
|
||||
|
||||
url = reverse('stock-item-create')
|
||||
|
||||
response = self.client.get(url, {'part': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.client.get(url, {'part': 999}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Copy from a valid item, valid location
|
||||
response = self.client.get(url, {'location': 1, 'copy': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Copy from an invalid item, invalid location
|
||||
response = self.client.get(url, {'location': 999, 'copy': 9999}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_create_stock_with_expiry(self):
|
||||
"""
|
||||
Test creation of stock item of a part with an expiry date.
|
||||
The initial value for the "expiry_date" field should be pre-filled,
|
||||
and should be in the future!
|
||||
"""
|
||||
|
||||
# First, ensure that the expiry date feature is enabled!
|
||||
InvenTreeSetting.set_setting('STOCK_ENABLE_EXPIRY', True, self.user)
|
||||
|
||||
url = reverse('stock-item-create')
|
||||
|
||||
response = self.client.get(url, {'part': 25}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# We are expecting 10 days in the future
|
||||
expiry = datetime.now().date() + timedelta(10)
|
||||
|
||||
expected = f'name=\\\\"expiry_date\\\\" value=\\\\"{expiry.isoformat()}\\\\"'
|
||||
|
||||
self.assertIn(expected, str(response.content))
|
||||
|
||||
# Now check with a part which does *not* have a default expiry period
|
||||
response = self.client.get(url, {'part': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
|
||||
expected = 'name=\\\\"expiry_date\\\\" placeholder=\\\\"\\\\"'
|
||||
|
||||
self.assertIn(expected, str(response.content))
|
||||
|
||||
|
||||
class StockOwnershipTest(StockViewTestCase):
|
||||
""" Tests for stock ownership views """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user