mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add more tests for order API (#4088)
* Force PO duplicate to fail * Add filter by part and supplier_part in tests * Fix syntax error * Add tests for pending, received, has_pricing status - amounts to be checked * Remove check which doesn't work as expected * Fix amount in one test; add LIST_URL where required * Change some numbers * Add tests for filtering PO Line items * Change name of class to fit better with others * Add tests for SO line item filters has_pricing and completed * Use variable for number of SO line items * Add another test for assigned_to_me for PO
This commit is contained in:
parent
eda0e74cb4
commit
d9e99e38d2
@ -56,6 +56,10 @@ class PurchaseOrderTest(OrderTest):
|
||||
# List *ALL* PurchaseOrder items
|
||||
self.filter({}, 7)
|
||||
|
||||
# Filter by assigned-to-me
|
||||
self.filter({'assigned_to_me': 1}, 0)
|
||||
self.filter({'assigned_to_me': 0}, 7)
|
||||
|
||||
# Filter by supplier
|
||||
self.filter({'supplier': 1}, 1)
|
||||
self.filter({'supplier': 3}, 5)
|
||||
@ -68,6 +72,15 @@ class PurchaseOrderTest(OrderTest):
|
||||
self.filter({'status': 10}, 3)
|
||||
self.filter({'status': 40}, 1)
|
||||
|
||||
# Filter by "part"
|
||||
self.filter({'part': 1}, 2)
|
||||
self.filter({'part': 2}, 0) # Part not assigned to any PO
|
||||
|
||||
# Filter by "supplier_part"
|
||||
self.filter({'supplier_part': 1}, 1)
|
||||
self.filter({'supplier_part': 3}, 2)
|
||||
self.filter({'supplier_part': 4}, 0)
|
||||
|
||||
def test_overdue(self):
|
||||
"""Test "overdue" status."""
|
||||
self.filter({'overdue': True}, 0)
|
||||
@ -247,6 +260,20 @@ class PurchaseOrderTest(OrderTest):
|
||||
del data['pk']
|
||||
del data['reference']
|
||||
|
||||
# Duplicate with non-existent PK to provoke error
|
||||
data['duplicate_order'] = 10000001
|
||||
data['duplicate_line_items'] = True
|
||||
data['duplicate_extra_lines'] = False
|
||||
|
||||
data['reference'] = 'PO-9999'
|
||||
|
||||
# Duplicate via the API
|
||||
response = self.post(
|
||||
reverse('api-po-list'),
|
||||
data,
|
||||
expected_code=400
|
||||
)
|
||||
|
||||
data['duplicate_order'] = 1
|
||||
data['duplicate_line_items'] = True
|
||||
data['duplicate_extra_lines'] = False
|
||||
@ -375,6 +402,29 @@ class PurchaseOrderTest(OrderTest):
|
||||
self.assertEqual(order.get_metadata('yam'), 'yum')
|
||||
|
||||
|
||||
class PurchaseOrderLineItemTest(OrderTest):
|
||||
"""Unit tests for PurchaseOrderLineItems."""
|
||||
|
||||
LIST_URL = reverse('api-po-line-list')
|
||||
|
||||
def test_po_line_list(self):
|
||||
"""Test the PurchaseOrderLine list API endpoint"""
|
||||
# List *ALL* PurchaseOrderLine items
|
||||
self.filter({}, 5)
|
||||
|
||||
# Filter by pending status
|
||||
self.filter({'pending': 1}, 5)
|
||||
self.filter({'pending': 0}, 0)
|
||||
|
||||
# Filter by received status
|
||||
self.filter({'received': 1}, 0)
|
||||
self.filter({'received': 0}, 5)
|
||||
|
||||
# Filter by has_pricing status
|
||||
self.filter({'has_pricing': 1}, 0)
|
||||
self.filter({'has_pricing': 0}, 5)
|
||||
|
||||
|
||||
class PurchaseOrderDownloadTest(OrderTest):
|
||||
"""Unit tests for downloading PurchaseOrder data via the API endpoint."""
|
||||
|
||||
@ -1015,6 +1065,8 @@ class SalesOrderTest(OrderTest):
|
||||
class SalesOrderLineItemTest(OrderTest):
|
||||
"""Tests for the SalesOrderLineItem API."""
|
||||
|
||||
LIST_URL = reverse('api-so-line-list')
|
||||
|
||||
def setUp(self):
|
||||
"""Init routine for this unit test class"""
|
||||
super().setUp()
|
||||
@ -1087,6 +1139,14 @@ class SalesOrderLineItemTest(OrderTest):
|
||||
|
||||
self.assertEqual(response.data['count'], n_parts)
|
||||
|
||||
# Filter by has_pricing status
|
||||
self.filter({'has_pricing': 1}, 0)
|
||||
self.filter({'has_pricing': 0}, n)
|
||||
|
||||
# Filter by has_pricing status
|
||||
self.filter({'completed': 1}, 0)
|
||||
self.filter({'completed': 0}, n)
|
||||
|
||||
|
||||
class SalesOrderDownloadTest(OrderTest):
|
||||
"""Unit tests for downloading SalesOrder data via the API endpoint."""
|
||||
|
Loading…
Reference in New Issue
Block a user