mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add unit test
This commit is contained in:
parent
6d448d8475
commit
8c78d3b8ea
@ -418,9 +418,9 @@ class PurchaseOrder(Order):
|
||||
barcode = ''
|
||||
|
||||
if not self.status == PurchaseOrderStatus.PLACED:
|
||||
raise ValidationError({
|
||||
"status": _("Lines can only be received against an order marked as 'Placed'")
|
||||
})
|
||||
raise ValidationError(
|
||||
"Lines can only be received against an order marked as 'PLACED'"
|
||||
)
|
||||
|
||||
try:
|
||||
if not (quantity % 1 == 0):
|
||||
|
@ -401,10 +401,7 @@ class PurchaseOrderReceiveTest(OrderTest):
|
||||
self.assertEqual(line_1.received, 0)
|
||||
self.assertEqual(line_2.received, 50)
|
||||
|
||||
# Receive two separate line items against this order
|
||||
self.post(
|
||||
self.url,
|
||||
{
|
||||
valid_data = {
|
||||
'items': [
|
||||
{
|
||||
'line_item': 1,
|
||||
@ -419,7 +416,30 @@ class PurchaseOrderReceiveTest(OrderTest):
|
||||
}
|
||||
],
|
||||
'location': 1, # Default location
|
||||
},
|
||||
}
|
||||
|
||||
# Before posting "valid" data, we will mark the purchase order as "pending"
|
||||
# In this case we do expect an error!
|
||||
order = PurchaseOrder.objects.get(pk=1)
|
||||
order.status = PurchaseOrderStatus.PENDING
|
||||
order.save()
|
||||
|
||||
response = self.post(
|
||||
self.url,
|
||||
valid_data,
|
||||
expected_code=400
|
||||
)
|
||||
|
||||
self.assertIn('can only be received against', str(response.data))
|
||||
|
||||
# Now, set the PO back to "PLACED" so the items can be received
|
||||
order.status = PurchaseOrderStatus.PLACED
|
||||
order.save()
|
||||
|
||||
# Receive two separate line items against this order
|
||||
self.post(
|
||||
self.url,
|
||||
valid_data,
|
||||
expected_code=201,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user