Skip to content

Commit f05ed5c

Browse files
Albert Camachoacamacho82
authored andcommitted
updating unittests in order to support the new changes made
1 parent 80bb9f9 commit f05ed5c

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

tests/CLI/modules/order_tests.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,13 @@ def test_location_list(self):
210210

211211
def _get_order_items(self):
212212
item1 = {'keyName': 'ITEM1', 'description': 'description1',
213-
'prices': [{'id': 1111, 'locationGroupId': None}]}
213+
'itemCategory': {'categoryCode': 'cat1'},
214+
'prices': [{'id': 1111, 'locationGroupId': None,
215+
'categories': [{'categoryCode': 'cat1'}]}]}
214216
item2 = {'keyName': 'ITEM2', 'description': 'description2',
215-
'prices': [{'id': 2222, 'locationGroupId': None}]}
217+
'itemCategory': {'categoryCode': 'cat2'},
218+
'prices': [{'id': 2222, 'locationGroupId': None,
219+
'categories': [{'categoryCode': 'cat2'}]}]}
216220

217221
return [item1, item2]
218222

tests/managers/ordering_tests.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -283,30 +283,33 @@ def test_get_preset_by_key_preset_not_found(self):
283283
self.assertEqual('Preset {} does not exist in package {}'.format(keyname, 'PACKAGE_KEYNAME'), str(exc))
284284

285285
def test_get_price_id_list(self):
286-
price1 = {'id': 1234, 'locationGroupId': None}
287-
item1 = {'id': 1111, 'keyName': 'ITEM1', 'prices': [price1]}
288-
price2 = {'id': 5678, 'locationGroupId': None}
289-
item2 = {'id': 2222, 'keyName': 'ITEM2', 'prices': [price2]}
286+
category1 = {'categoryCode': 'cat1'}
287+
price1 = {'id': 1234, 'locationGroupId': None, 'itemCategory': [category1]}
288+
item1 = {'id': 1111, 'keyName': 'ITEM1', 'itemCategory': category1, 'prices': [price1]}
289+
category2 = {'categoryCode': 'cat2'}
290+
price2 = {'id': 5678, 'locationGroupId': None, 'categories': [category2]}
291+
item2 = {'id': 2222, 'keyName': 'ITEM2', 'itemCategory': category2, 'prices': [price2]}
290292

291293
with mock.patch.object(self.ordering, 'list_items') as list_mock:
292294
list_mock.return_value = [item1, item2]
293295

294296
prices = self.ordering.get_price_id_list('PACKAGE_KEYNAME', ['ITEM1', 'ITEM2'])
295297

296-
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, keyName, prices')
298+
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, itemCategory, keyName, prices[categories]')
297299
self.assertEqual([price1['id'], price2['id']], prices)
298300

299301
def test_get_price_id_list_item_not_found(self):
300-
price1 = {'id': 1234, 'locationGroupId': ''}
301-
item1 = {'id': 1111, 'keyName': 'ITEM1', 'prices': [price1]}
302+
category1 = {'categoryCode': 'cat1'}
303+
price1 = {'id': 1234, 'locationGroupId': '', 'categories': [category1]}
304+
item1 = {'id': 1111, 'keyName': 'ITEM1', 'itemCategory': category1, 'prices': [price1]}
302305

303306
with mock.patch.object(self.ordering, 'list_items') as list_mock:
304307
list_mock.return_value = [item1]
305308

306309
exc = self.assertRaises(exceptions.SoftLayerError,
307310
self.ordering.get_price_id_list,
308311
'PACKAGE_KEYNAME', ['ITEM2'])
309-
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, keyName, prices')
312+
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, itemCategory, keyName, prices[categories]')
310313
self.assertEqual("Item ITEM2 does not exist for package PACKAGE_KEYNAME", str(exc))
311314

312315
def test_generate_no_complex_type(self):
@@ -460,30 +463,34 @@ def test_get_location_id_int(self):
460463

461464
def test_location_group_id_none(self):
462465
# RestTransport uses None for empty locationGroupId
463-
price1 = {'id': 1234, 'locationGroupId': None}
464-
item1 = {'id': 1111, 'keyName': 'ITEM1', 'prices': [price1]}
465-
price2 = {'id': 5678, 'locationGroupId': None}
466-
item2 = {'id': 2222, 'keyName': 'ITEM2', 'prices': [price2]}
466+
category1 = {'categoryCode': 'cat1'}
467+
price1 = {'id': 1234, 'locationGroupId': None, 'categories': [category1]}
468+
item1 = {'id': 1111, 'keyName': 'ITEM1', 'itemCategory': category1, 'prices': [price1]}
469+
category2 = {'categoryCode': 'cat2'}
470+
price2 = {'id': 5678, 'locationGroupId': None, 'categories': [category2]}
471+
item2 = {'id': 2222, 'keyName': 'ITEM2', 'itemCategory': category2, 'prices': [price2]}
467472

468473
with mock.patch.object(self.ordering, 'list_items') as list_mock:
469474
list_mock.return_value = [item1, item2]
470475

471476
prices = self.ordering.get_price_id_list('PACKAGE_KEYNAME', ['ITEM1', 'ITEM2'])
472477

473-
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, keyName, prices')
478+
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, itemCategory, keyName, prices[categories]')
474479
self.assertEqual([price1['id'], price2['id']], prices)
475480

476481
def test_location_groud_id_empty(self):
477482
# XMLRPCtransport uses '' for empty locationGroupId
478-
price1 = {'id': 1234, 'locationGroupId': ''}
479-
item1 = {'id': 1111, 'keyName': 'ITEM1', 'prices': [price1]}
480-
price2 = {'id': 5678, 'locationGroupId': ""}
481-
item2 = {'id': 2222, 'keyName': 'ITEM2', 'prices': [price2]}
483+
category1 = {'categoryCode': 'cat1'}
484+
price1 = {'id': 1234, 'locationGroupId': '', 'categories': [category1]}
485+
item1 = {'id': 1111, 'keyName': 'ITEM1', 'itemCategory': category1, 'prices': [price1]}
486+
category2 = {'categoryCode': 'cat2'}
487+
price2 = {'id': 5678, 'locationGroupId': "", 'categories': [category2]}
488+
item2 = {'id': 2222, 'keyName': 'ITEM2', 'itemCategory': category2, 'prices': [price2]}
482489

483490
with mock.patch.object(self.ordering, 'list_items') as list_mock:
484491
list_mock.return_value = [item1, item2]
485492

486493
prices = self.ordering.get_price_id_list('PACKAGE_KEYNAME', ['ITEM1', 'ITEM2'])
487494

488-
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, keyName, prices')
495+
list_mock.assert_called_once_with('PACKAGE_KEYNAME', mask='id, itemCategory, keyName, prices[categories]')
489496
self.assertEqual([price1['id'], price2['id']], prices)

0 commit comments

Comments
 (0)