From e95dcbd1a242d094e70b5e8036c83e66dac4a994 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 29 Dec 2024 11:40:46 +0100 Subject: [PATCH] Add unit test for mouser package --- inventree_supplier_sync/test_supplier_sync.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/inventree_supplier_sync/test_supplier_sync.py b/inventree_supplier_sync/test_supplier_sync.py index 657f802..4e32a9c 100644 --- a/inventree_supplier_sync/test_supplier_sync.py +++ b/inventree_supplier_sync/test_supplier_sync.py @@ -22,6 +22,24 @@ def test_reformat_mouser_price(self): self.assertEqual(Mouser.reformat_mouser_price(self, ''), 0) self.assertEqual(Mouser.reformat_mouser_price(self, 'Mumpitz'), 0) + def test_get_mouser_package(self): + + SettingsMixin.set_setting(self, key='MOUSERLANGUAGE', value='German') + part_data = {'ProductAttributes': [ + {'AttributeName': 'Verpackung', 'AttributeValue': 'Reel'}, + {'AttributeName': 'Verpackung', 'AttributeValue': 'Cut Tape'}, + {'AttributeName': 'Verpackung', 'AttributeValue': 'MouseReel', + 'AttributeCost': 'Für die MouseReel™ wird Ihrem Warenkorb automatisch eine Gebühr...'}, + {'AttributeName': 'Standardpackungsmenge', 'AttributeValue': '3000'}]} + + self.assertEqual(Mouser.get_mouser_package(self, part_data), 'Reel, Cut Tape, MouseReel, ') + + SettingsMixin.set_setting(self, key='MOUSERLANGUAGE', value='English') + self.assertEqual(Mouser.get_mouser_package(self, part_data), '') + + part_data = {} + self.assertEqual(Mouser.get_mouser_package(self, part_data), None) + def test_should_be_updated(self): cat_include = PartCategory.objects.create(name='cat_include') cat_ignore = PartCategory.objects.create(name='cat_ignore', metadata={"SupplierSyncPlugin": {"SyncIgnore": True}})