mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixes for unit tests
This commit is contained in:
parent
563deb5ffa
commit
e7d78db87b
@ -4,6 +4,7 @@ Part database model definitions
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import decimal
|
||||
|
||||
import os
|
||||
import logging
|
||||
@ -1530,10 +1531,13 @@ class Part(MPTTModel):
|
||||
for item in self.get_bom_items().all().select_related('sub_part'):
|
||||
|
||||
if item.sub_part.pk == self.pk:
|
||||
print("Warning: Item contains itself in BOM")
|
||||
logger.warning(f"WARNING: BomItem ID {item.pk} contains itself in BOM")
|
||||
continue
|
||||
|
||||
prices = item.sub_part.get_price_range(quantity * item.quantity, internal=internal, purchase=purchase)
|
||||
q = decimal.Decimal(quantity)
|
||||
i = decimal.Decimal(item.quantity)
|
||||
|
||||
prices = item.sub_part.get_price_range(q * i, internal=internal, purchase=purchase)
|
||||
|
||||
if prices is None:
|
||||
continue
|
||||
|
@ -277,7 +277,7 @@ class PartAPITest(InvenTreeAPITestCase):
|
||||
""" There should be 4 BomItem objects in the database """
|
||||
url = reverse('api-bom-list')
|
||||
response = self.client.get(url, format='json')
|
||||
self.assertEqual(len(response.data), 4)
|
||||
self.assertEqual(len(response.data), 5)
|
||||
|
||||
def test_get_bom_detail(self):
|
||||
# Get the detail for a single BomItem
|
||||
|
@ -120,7 +120,13 @@ class BomItemTest(TestCase):
|
||||
|
||||
def test_pricing(self):
|
||||
self.bob.get_price(1)
|
||||
self.assertEqual(self.bob.get_bom_price_range(1, internal=True), (Decimal(84.5), Decimal(89.5)))
|
||||
self.assertEqual(
|
||||
self.bob.get_bom_price_range(1, internal=True),
|
||||
(Decimal(29.5), Decimal(89.5))
|
||||
)
|
||||
# remove internal price for R_2K2_0805
|
||||
self.r1.internal_price_breaks.delete()
|
||||
self.assertEqual(self.bob.get_bom_price_range(1, internal=True), (Decimal(82.5), Decimal(87.5)))
|
||||
self.assertEqual(
|
||||
self.bob.get_bom_price_range(1, internal=True),
|
||||
(Decimal(27.5), Decimal(87.5))
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user