Skip to content

Commit 63a4919

Browse files
Merge pull request #1679 from allmightyspiff/issues1678
item-list fix
2 parents 950a54b + 123a749 commit 63a4919

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

SoftLayer/CLI/order/item_list.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
from SoftLayer.managers import ordering
99
from SoftLayer.utils import lookup
1010

11-
COLUMNS = ['category', 'keyName', 'description', 'priceId']
12-
COLUMNS_ITEM_PRICES = ['keyName', 'priceId', 'Hourly', 'Monthly', 'Restriction']
13-
COLUMNS_ITEM_PRICES_LOCATION = ['keyName', 'priceId', 'Hourly', 'Monthly', 'Restriction']
11+
COLUMNS = ['Category', 'KeyName', 'Description', 'Price Id']
12+
COLUMNS_ITEM_PRICES = ['KeyName', 'Price Id', 'Hourly', 'Monthly', 'Restriction']
13+
COLUMNS_ITEM_PRICES_LOCATION = ['KeyName', 'Price Id', 'Hourly', 'Monthly', 'Restriction']
1414

1515

1616
@click.command(cls=SLCommand)
1717
@click.argument('package_keyname')
1818
@click.option('--keyword', '-k', help="A word (or string) used to filter item names.")
1919
@click.option('--category', '-c', help="Category code to filter items by")
20-
@click.option('--prices', '-p', is_flag=True, help='Use --prices to list the server item prices, and to list the '
21-
'Item Prices by location, add it to the --prices option using '
22-
'location KeyName, e.g. --prices AMSTERDAM02')
20+
@click.option('--prices', '-p', is_flag=True,
21+
help='Use --prices to list the server item prices, and to list the '
22+
'Item Prices by location, add it to the --prices option using '
23+
'location KeyName, e.g. --prices AMSTERDAM02')
2324
@click.argument('location', required=False)
2425
@environment.pass_env
2526
def cli(env, package_keyname, keyword, category, prices, location=None):
@@ -66,7 +67,7 @@ def cli(env, package_keyname, keyword, category, prices, location=None):
6667
for item in sorted_items[category_name]:
6768
table_items_detail.add_row([category_name, item['keyName'], item['description'], get_price(item)])
6869
tables.append(table_items_detail)
69-
env.fout(formatting.listing(tables, separator='\n'))
70+
env.fout(tables)
7071

7172

7273
def sort_items(items):

tests/CLI/modules/order_tests.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def test_item_list_prices(self):
5050

5151
self.assert_no_fail(result)
5252
output = json.loads(result.output)
53-
self.assertEqual(output[0][0]['priceId'], 1007)
53+
self.assertEqual(output[0][0]['Price Id'], 1007)
5454
self.assertEqual(output[0][1]['Restriction'], '- - - -')
55-
self.assertEqual(output[0][1]['keyName'], 'KeyName015')
55+
self.assertEqual(output[0][1]['KeyName'], 'KeyName015')
5656
self.assert_called_with('SoftLayer_Product_Package', 'getItems')
5757

5858
def test_item_list_location_keyname(self):
@@ -61,8 +61,8 @@ def test_item_list_location_keyname(self):
6161
self.assert_no_fail(result)
6262
output = json.loads(result.output)
6363
self.assertEqual(output[0][0]['Hourly'], 0.0)
64-
self.assertEqual(output[0][1]['keyName'], 'KeyName015')
65-
self.assertEqual(output[0][1]['priceId'], 1144)
64+
self.assertEqual(output[0][1]['KeyName'], 'KeyName015')
65+
self.assertEqual(output[0][1]['Price Id'], 1144)
6666
self.assert_called_with('SoftLayer_Product_Package', 'getItemPrices')
6767

6868
def test_item_list_location_name(self):
@@ -71,8 +71,8 @@ def test_item_list_location_name(self):
7171
self.assert_no_fail(result)
7272
output = json.loads(result.output)
7373
self.assertEqual(output[0][0]['Hourly'], 0.0)
74-
self.assertEqual(output[0][1]['keyName'], 'KeyName015')
75-
self.assertEqual(output[0][1]['priceId'], 1144)
74+
self.assertEqual(output[0][1]['KeyName'], 'KeyName015')
75+
self.assertEqual(output[0][1]['Price Id'], 1144)
7676
self.assert_called_with('SoftLayer_Product_Package', 'getItemPrices')
7777

7878
def test_item_list_category_keyword(self):
@@ -81,8 +81,8 @@ def test_item_list_category_keyword(self):
8181
self.assert_no_fail(result)
8282
output = json.loads(result.output)
8383
self.assertEqual(output[0][0]['Hourly'], 0.0)
84-
self.assertEqual(output[0][1]['keyName'], 'KeyName015')
85-
self.assertEqual(output[0][1]['priceId'], 1144)
84+
self.assertEqual(output[0][1]['KeyName'], 'KeyName015')
85+
self.assertEqual(output[0][1]['Price Id'], 1144)
8686
self.assert_called_with('SoftLayer_Product_Package', 'getItemPrices')
8787

8888
def test_package_list(self):

0 commit comments

Comments
 (0)