Add a test fixture for orders

This commit is contained in:
Oliver Walters 2019-06-17 19:47:16 +10:00
parent 78bfc0b6a8
commit 0857ec61fd
4 changed files with 82 additions and 1 deletions

View File

@ -1,14 +1,17 @@
# Sample company data
- model: company.company
pk: 1
fields:
name: ACME
description: A Cool Military Enterprise
- model: company.company
pk: 2
fields:
name: Appel Computers
description: Think more differenter
- model: company.company
pk: 3
fields:
name: Zerg Corp
description: We eat the competition

View File

@ -0,0 +1,3 @@
"""
The Order module is responsible for managing Orders
"""

View 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

View File

@ -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)