Skip to content

Commit d6a9453

Browse files
check for default location set to None instead of empty string
1 parent e081d7d commit d6a9453

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

SoftLayer/managers/ordering.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,14 @@ def get_location_id(self, location):
482482
:returns: integer id of the datacenter
483483
"""
484484

485+
if isinstance(location, int):
486+
return location
485487
mask = "mask[id,name,regions[keyname]]"
486488
if match(r'[a-zA-Z]{3}[0-9]{2}', location) is not None:
487489
search = {'name': {'operation': location}}
488490
else:
489491
search = {'regions': {'keyname': {'operation': location}}}
490492
datacenter = self.client.call('SoftLayer_Location', 'getDatacenters', mask=mask, filter=search)
491-
# [{'id': 1854895, 'name': 'dal13', 'regions': [{'keyname': 'DALLAS13'}]}]
492493
if len(datacenter) != 1:
493494
raise exceptions.SoftLayerError("Unable to find location: %s" % location)
494495
return datacenter[0]['id']

tests/CLI/modules/order_tests.py

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

211211
def _get_order_items(self):
212212
item1 = {'keyName': 'ITEM1', 'description': 'description1',
213-
'prices': [{'id': 1111, 'locationGroupId': ''}]}
213+
'prices': [{'id': 1111, 'locationGroupId': None}]}
214214
item2 = {'keyName': 'ITEM2', 'description': 'description2',
215-
'prices': [{'id': 2222, 'locationGroupId': ''}]}
215+
'prices': [{'id': 2222, 'locationGroupId': None}]}
216216

217217
return [item1, item2]
218218

tests/managers/ordering_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ def test_get_preset_by_key_preset_not_found(self):
225225
self.assertEqual('Preset {} does not exist in package {}'.format(keyname, 'PACKAGE_KEYNAME'), str(exc))
226226

227227
def test_get_price_id_list(self):
228-
price1 = {'id': 1234, 'locationGroupId': ''}
228+
price1 = {'id': 1234, 'locationGroupId': None}
229229
item1 = {'id': 1111, 'keyName': 'ITEM1', 'prices': [price1]}
230-
price2 = {'id': 5678, 'locationGroupId': ''}
230+
price2 = {'id': 5678, 'locationGroupId': None}
231231
item2 = {'id': 2222, 'keyName': 'ITEM2', 'prices': [price2]}
232232

233233
with mock.patch.object(self.ordering, 'list_items') as list_mock:

0 commit comments

Comments
 (0)