mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 13:06:45 +00:00
Add a test fixture for orders
This commit is contained in:
parent
78bfc0b6a8
commit
0857ec61fd
@ -1,14 +1,17 @@
|
|||||||
# Sample company data
|
# Sample company data
|
||||||
|
|
||||||
- model: company.company
|
- model: company.company
|
||||||
|
pk: 1
|
||||||
fields:
|
fields:
|
||||||
name: ACME
|
name: ACME
|
||||||
description: A Cool Military Enterprise
|
description: A Cool Military Enterprise
|
||||||
- model: company.company
|
- model: company.company
|
||||||
|
pk: 2
|
||||||
fields:
|
fields:
|
||||||
name: Appel Computers
|
name: Appel Computers
|
||||||
description: Think more differenter
|
description: Think more differenter
|
||||||
- model: company.company
|
- model: company.company
|
||||||
|
pk: 3
|
||||||
fields:
|
fields:
|
||||||
name: Zerg Corp
|
name: Zerg Corp
|
||||||
description: We eat the competition
|
description: We eat the competition
|
@ -0,0 +1,3 @@
|
|||||||
|
"""
|
||||||
|
The Order module is responsible for managing Orders
|
||||||
|
"""
|
43
InvenTree/order/fixtures/order.yaml
Normal file
43
InvenTree/order/fixtures/order.yaml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# PurchaseOrder and PurchaseOrderLineItem objects for testing
|
||||||
|
|
||||||
|
# Ordering some screws from ACME
|
||||||
|
- model: order.purchaseorder
|
||||||
|
pk: 1
|
||||||
|
fields:
|
||||||
|
reference: 0001
|
||||||
|
description: "Ordering some screws"
|
||||||
|
supplier: 1
|
||||||
|
|
||||||
|
# Ordering some screws from Zerg Corp
|
||||||
|
- model: order.purchaseorder
|
||||||
|
pk: 2
|
||||||
|
fields:
|
||||||
|
reference: 0002
|
||||||
|
description: "Ordering some more screws"
|
||||||
|
supplier: 3
|
||||||
|
|
||||||
|
# Add some line items against PO 0001
|
||||||
|
|
||||||
|
# 100 x ACME0001 (M2x4 LPHS)
|
||||||
|
- model: order.purchaseorderlineitem
|
||||||
|
fields:
|
||||||
|
order: 1
|
||||||
|
part: 1
|
||||||
|
quantity: 100
|
||||||
|
|
||||||
|
# 250 x ACME0002 (M2x4 LPHS)
|
||||||
|
# Partially received (50)
|
||||||
|
- model: order.purchaseorderlineitem
|
||||||
|
fields:
|
||||||
|
order: 1
|
||||||
|
part: 2
|
||||||
|
quantity: 250
|
||||||
|
received: 50
|
||||||
|
|
||||||
|
# 100 x ZERGLPHS (M2x4 LPHS)
|
||||||
|
- model: order.purchaseorderlineitem
|
||||||
|
fields:
|
||||||
|
order: 2
|
||||||
|
part: 3
|
||||||
|
quantity: 100
|
||||||
|
|
@ -1 +1,33 @@
|
|||||||
# TODO - Implement tests for the order app
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from part.models import Part
|
||||||
|
|
||||||
|
class OrderTest(TestCase):
|
||||||
|
"""
|
||||||
|
Tests to ensure that the order models are functioning correctly.
|
||||||
|
"""
|
||||||
|
|
||||||
|
fixtures = [
|
||||||
|
'company',
|
||||||
|
'supplier_part',
|
||||||
|
'category',
|
||||||
|
'part',
|
||||||
|
'location',
|
||||||
|
'stock',
|
||||||
|
'order'
|
||||||
|
]
|
||||||
|
|
||||||
|
def test_on_order(self):
|
||||||
|
""" There should be 3 separate items on order for the M2x4 LPHS part """
|
||||||
|
|
||||||
|
part = Part.objects.get(name='M2x4 LPHS')
|
||||||
|
|
||||||
|
open_orders = []
|
||||||
|
|
||||||
|
for supplier in part.supplier_parts.all():
|
||||||
|
open_orders += supplier.open_orders()
|
||||||
|
|
||||||
|
self.assertEqual(len(open_orders), 3)
|
||||||
|
|
||||||
|
# Test the total on-order quantity
|
||||||
|
self.assertEqual(part.on_order, 400)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user