mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-28 03:49:20 +00:00
Adjust unit tests
This commit is contained in:
@@ -1353,7 +1353,7 @@ class BuildOutputCreateTest(BuildAPITest):
|
|||||||
url, data={'quantity': 5, 'serial_numbers': '1,2,3-5'}, expected_code=201
|
url, data={'quantity': 5, 'serial_numbers': '1,2,3-5'}, expected_code=201
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build outputs have incdeased
|
# Build outputs have increased
|
||||||
self.assertEqual(n_outputs + 5, build.output_count)
|
self.assertEqual(n_outputs + 5, build.output_count)
|
||||||
|
|
||||||
# Stock items have increased
|
# Stock items have increased
|
||||||
@@ -1466,7 +1466,7 @@ class BuildOutputScrapTest(BuildAPITest):
|
|||||||
'location': 1,
|
'location': 1,
|
||||||
'notes': 'Should succeed',
|
'notes': 'Should succeed',
|
||||||
},
|
},
|
||||||
expected_code=201,
|
expected_code=200,
|
||||||
)
|
)
|
||||||
|
|
||||||
# There should still be three outputs associated with this build
|
# There should still be three outputs associated with this build
|
||||||
@@ -1534,7 +1534,7 @@ class BuildOutputScrapTest(BuildAPITest):
|
|||||||
|
|
||||||
# Partially complete the output (with a valid quantity)
|
# Partially complete the output (with a valid quantity)
|
||||||
data['outputs'][0]['quantity'] = 4
|
data['outputs'][0]['quantity'] = 4
|
||||||
self.post(url, data, expected_code=201)
|
self.post(url, data, expected_code=200)
|
||||||
|
|
||||||
build.refresh_from_db()
|
build.refresh_from_db()
|
||||||
output.refresh_from_db()
|
output.refresh_from_db()
|
||||||
@@ -1571,13 +1571,22 @@ class BuildOutputCancelTest(BuildAPITest):
|
|||||||
set_global_setting('STOCK_ALLOW_DELETE_SERIALIZED', True)
|
set_global_setting('STOCK_ALLOW_DELETE_SERIALIZED', True)
|
||||||
url = reverse('api-build-output-delete', kwargs={'pk': build.pk})
|
url = reverse('api-build-output-delete', kwargs={'pk': build.pk})
|
||||||
|
|
||||||
self.post(url, data={'outputs': [{'output': output_ids[0]}]}, expected_code=201)
|
self.post(url, data={'outputs': [{'output': output_ids[0]}]}, expected_code=200)
|
||||||
|
|
||||||
# Prevent deletion of serialized stock items, and try again
|
# Prevent deletion of serialized stock items, and try again
|
||||||
# Note that this should still succeed, independent of the global setting
|
# Note that this should still succeed, independent of the global setting
|
||||||
set_global_setting('STOCK_ALLOW_DELETE_SERIALIZED', False)
|
set_global_setting('STOCK_ALLOW_DELETE_SERIALIZED', False)
|
||||||
|
|
||||||
self.post(url, data={'outputs': [{'output': output_ids[1]}]}, expected_code=201)
|
response = self.post(
|
||||||
|
url, data={'outputs': [{'output': output_ids[1]}]}, expected_code=200
|
||||||
|
)
|
||||||
|
|
||||||
|
# Response should be the task info - the cancellation is performed asynchronously
|
||||||
|
self.assertIn('task_id', response.data)
|
||||||
|
self.assertFalse(response.data['exists'])
|
||||||
|
self.assertFalse(response.data['pending'])
|
||||||
|
self.assertTrue(response.data['complete'])
|
||||||
|
self.assertTrue(response.data['success'])
|
||||||
|
|
||||||
# The outputs should have been scrapped
|
# The outputs should have been scrapped
|
||||||
self.assertEqual(build.build_outputs.count(), N)
|
self.assertEqual(build.build_outputs.count(), N)
|
||||||
|
|||||||
Reference in New Issue
Block a user