Skip to content

Commit

Permalink
Add unit test for mouser package
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Dec 29, 2024
1 parent b4fa171 commit 57313e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inventree_supplier_sync/supplier_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SupplierSyncPlugin(AppMixin, ScheduleMixin, SettingsMixin, PanelMixin, Inv
'member': {
'func': 'update_part',
'schedule': 'I',
'minutes': 5,
'minutes': 1,
}
}

Expand Down
18 changes: 18 additions & 0 deletions inventree_supplier_sync/test_supplier_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}})
Expand Down

0 comments on commit 57313e7

Please sign in to comment.