Skip to content

Commit 13e6383

Browse files
Albert Camachoacamacho82
authored andcommitted
Adding order into orderContainers, unittests were also updated, it should fix the issue 966.
1 parent 5439d63 commit 13e6383

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

SoftLayer/managers/ordering.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ def generate_order(self, package_keyname, location, item_keynames, complex_type=
445445
:param int quantity: The number of resources to order
446446
447447
"""
448+
container = {}
448449
order = {}
449450
extras = extras or {}
450451

@@ -470,7 +471,10 @@ def generate_order(self, package_keyname, location, item_keynames, complex_type=
470471

471472
price_ids = self.get_price_id_list(package_keyname, item_keynames)
472473
order['prices'] = [{'id': price_id} for price_id in price_ids]
473-
return order
474+
475+
container['orderContainers'] = [order]
476+
477+
return container
474478

475479
def package_locations(self, package_keyname):
476480
"""List datacenter locations for a package keyname

tests/managers/ordering_tests.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,15 @@ def test_generate_order_with_preset(self):
321321
complex_type = 'SoftLayer_Container_Foo'
322322
items = ['ITEM1', 'ITEM2']
323323
preset = 'PRESET_KEYNAME'
324-
expected_order = {'complexType': 'SoftLayer_Container_Foo',
325-
'location': 1854895,
326-
'packageId': 1234,
327-
'presetId': 5678,
328-
'prices': [{'id': 1111}, {'id': 2222}],
329-
'quantity': 1,
330-
'useHourlyPricing': True}
324+
expected_order = {'orderContainers': [
325+
{'complexType': 'SoftLayer_Container_Foo',
326+
'location': 1854895,
327+
'packageId': 1234,
328+
'presetId': 5678,
329+
'prices': [{'id': 1111}, {'id': 2222}],
330+
'quantity': 1,
331+
'useHourlyPricing': True}
332+
]}
331333

332334
mock_pkg, mock_preset, mock_get_ids = self._patch_for_generate()
333335

@@ -342,12 +344,14 @@ def test_generate_order(self):
342344
pkg = 'PACKAGE_KEYNAME'
343345
items = ['ITEM1', 'ITEM2']
344346
complex_type = 'My_Type'
345-
expected_order = {'complexType': 'My_Type',
346-
'location': 1854895,
347-
'packageId': 1234,
348-
'prices': [{'id': 1111}, {'id': 2222}],
349-
'quantity': 1,
350-
'useHourlyPricing': True}
347+
expected_order = {'orderContainers': [
348+
{'complexType': 'My_Type',
349+
'location': 1854895,
350+
'packageId': 1234,
351+
'prices': [{'id': 1111}, {'id': 2222}],
352+
'quantity': 1,
353+
'useHourlyPricing': True}
354+
]}
351355

352356
mock_pkg, mock_preset, mock_get_ids = self._patch_for_generate()
353357

0 commit comments

Comments
 (0)