Skip to content

Commit b04a046

Browse files
Albert Camachoacamacho82
authored andcommitted
Adding unittest to verify that gpu0 and gpu1 prices are retrieved when sending the same item twice in the order
1 parent f05ed5c commit b04a046

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/managers/ordering_tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,20 @@ def test_get_price_id_list_item_not_found(self):
312312
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, itemCategory, keyName, prices[categories]')
313313
self.assertEqual("Item ITEM2 does not exist for package PACKAGE_KEYNAME", str(exc))
314314

315+
def test_get_price_id_list_gpu_items_with_two_categories(self):
316+
# Specific for GPU prices which are differentiated by their category (gpu0, gpu1)
317+
price1 = {'id': 1234, 'locationGroupId': None, 'categories': [{'categoryCode': 'gpu1'}]}
318+
price2 = {'id': 5678, 'locationGroupId': None, 'categories': [{'categoryCode': 'gpu0'}]}
319+
item1 = {'id': 1111, 'keyName': 'ITEM1', 'itemCategory': {'categoryCode': 'gpu0'}, 'prices': [price1, price2]}
320+
321+
with mock.patch.object(self.ordering, 'list_items') as list_mock:
322+
list_mock.return_value = [item1, item1]
323+
324+
prices = self.ordering.get_price_id_list('PACKAGE_KEYNAME', ['ITEM1', 'ITEM1'])
325+
326+
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, itemCategory, keyName, prices[categories]')
327+
self.assertEqual([price2['id'], price1['id']], prices)
328+
315329
def test_generate_no_complex_type(self):
316330
pkg = 'PACKAGE_KEYNAME'
317331
items = ['ITEM1', 'ITEM2']

0 commit comments

Comments
 (0)