From baab9557561b2405e10ceca1cc73d839428efbe2 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 25 Feb 2022 17:17:34 +1100 Subject: [PATCH] Further fixes for unit tests --- InvenTree/build/test_build.py | 18 +++++++++--------- .../part/migrations/0056_auto_20201110_1125.py | 7 ++++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/InvenTree/build/test_build.py b/InvenTree/build/test_build.py index ab3a1a8901..116c705f61 100644 --- a/InvenTree/build/test_build.py +++ b/InvenTree/build/test_build.py @@ -62,20 +62,20 @@ class BuildTest(TestCase): ) # Create BOM item links for the parts - BomItem.objects.create( + self.bom_item_1 = BomItem.objects.create( part=self.assembly, sub_part=self.sub_part_1, quantity=5 ) - BomItem.objects.create( + self.bom_item_2 = BomItem.objects.create( part=self.assembly, sub_part=self.sub_part_2, quantity=3 ) # sub_part_3 is trackable! - BomItem.objects.create( + self.bom_item_3 = BomItem.objects.create( part=self.assembly, sub_part=self.sub_part_3, quantity=2 @@ -149,13 +149,13 @@ class BuildTest(TestCase): for output in self.build.get_build_outputs().all(): self.assertFalse(self.build.is_fully_allocated(output)) - self.assertFalse(self.build.is_bom_item_allocated(self.sub_part_1, self.output_1)) - self.assertFalse(self.build.is_bom_item_allocated(self.sub_part_2, self.output_2)) + self.assertFalse(self.build.is_bom_item_allocated(self.bom_item_1, self.output_1)) + self.assertFalse(self.build.is_bom_item_allocated(self.bom_item_2, self.output_2)) - self.assertEqual(self.build.unallocated_quantity(self.sub_part_1, self.output_1), 15) - self.assertEqual(self.build.unallocated_quantity(self.sub_part_1, self.output_2), 35) - self.assertEqual(self.build.unallocated_quantity(self.sub_part_2, self.output_1), 9) - self.assertEqual(self.build.unallocated_quantity(self.sub_part_2, self.output_2), 21) + self.assertEqual(self.build.unallocated_quantity(self.bom_item_1, self.output_1), 15) + self.assertEqual(self.build.unallocated_quantity(self.bom_item_1, self.output_2), 35) + self.assertEqual(self.build.unallocated_quantity(self.bom_item_2, self.output_1), 9) + self.assertEqual(self.build.unallocated_quantity(self.bom_item_2, self.output_2), 21) self.assertFalse(self.build.is_complete) diff --git a/InvenTree/part/migrations/0056_auto_20201110_1125.py b/InvenTree/part/migrations/0056_auto_20201110_1125.py index e78482db76..efb36b1812 100644 --- a/InvenTree/part/migrations/0056_auto_20201110_1125.py +++ b/InvenTree/part/migrations/0056_auto_20201110_1125.py @@ -1,5 +1,7 @@ # Generated by Django 3.0.7 on 2020-11-10 11:25 +import logging + from django.db import migrations from moneyed import CURRENCIES @@ -7,6 +9,9 @@ from django.db import migrations, connection from company.models import SupplierPriceBreak +logger = logging.getLogger('inventree') + + def migrate_currencies(apps, schema_editor): """ Migrate from the 'old' method of handling currencies, @@ -19,7 +24,7 @@ def migrate_currencies(apps, schema_editor): for the SupplierPriceBreak model, to a new django-money compatible currency. """ - print("Updating currency references for SupplierPriceBreak model...") + logger.info("Updating currency references for SupplierPriceBreak model...") # A list of available currency codes currency_codes = CURRENCIES.keys()