From a02f4913ddf1a68e395af28c29bf32e558717994 Mon Sep 17 00:00:00 2001 From: caberos Date: Thu, 11 Nov 2021 15:09:08 -0400 Subject: [PATCH 1/2] Add Item names to vs billing report --- SoftLayer/CLI/virt/billing.py | 6 +-- SoftLayer/fixtures/SoftLayer_Virtual_Guest.py | 35 ++++++++++---- SoftLayer/managers/vs.py | 2 +- tests/CLI/modules/vs/vs_tests.py | 48 +++++++++---------- 4 files changed, 53 insertions(+), 38 deletions(-) diff --git a/SoftLayer/CLI/virt/billing.py b/SoftLayer/CLI/virt/billing.py index 7312de8d8..ddc785361 100644 --- a/SoftLayer/CLI/virt/billing.py +++ b/SoftLayer/CLI/virt/billing.py @@ -28,11 +28,11 @@ def cli(env, identifier): table.add_row(['Billing Item Id', utils.lookup(result, 'billingItem', 'id')]) table.add_row(['Recurring Fee', utils.lookup(result, 'billingItem', 'recurringFee')]) table.add_row(['Total', utils.lookup(result, 'billingItem', 'nextInvoiceTotalRecurringAmount')]) - table.add_row(['Provision Date', utils.lookup(result, 'billingItem', 'provisionDate')]) + table.add_row(['Provision Date', utils.lookup(result, 'provisionDate')]) - price_table = formatting.Table(['Recurring Price']) + price_table = formatting.Table(['description', 'Recurring Price']) for item in utils.lookup(result, 'billingItem', 'children') or []: - price_table.add_row([item['nextInvoiceTotalRecurringAmount']]) + price_table.add_row([item['description'], item['nextInvoiceTotalRecurringAmount']]) table.add_row(['prices', price_table]) env.fout(table) diff --git a/SoftLayer/fixtures/SoftLayer_Virtual_Guest.py b/SoftLayer/fixtures/SoftLayer_Virtual_Guest.py index 5957949ce..4662b68f8 100644 --- a/SoftLayer/fixtures/SoftLayer_Virtual_Guest.py +++ b/SoftLayer/fixtures/SoftLayer_Virtual_Guest.py @@ -8,16 +8,31 @@ 'id': 6327, 'nextInvoiceTotalRecurringAmount': 1.54, 'children': [ - {'categoryCode': 'port_speed', - 'nextInvoiceTotalRecurringAmount': 1}, - {'categoryCode': 'guest_core', - 'nextInvoiceTotalRecurringAmount': 1}, - {'categoryCode': 'ram', - 'nextInvoiceTotalRecurringAmount': 1}, - {'categoryCode': 'guest_core', - 'nextInvoiceTotalRecurringAmount': 1}, - {'categoryCode': 'guest_disk1', - 'nextInvoiceTotalRecurringAmount': 1}, + { + 'categoryCode': 'ram', + 'description': '1 GB', + 'nextInvoiceTotalRecurringAmount': 1 + }, + { + 'categoryCode': 'remote_management', + 'description': 'Reboot / Remote Console', + 'nextInvoiceTotalRecurringAmount': 1 + }, + { + 'categoryCode': 'port_speed', + 'description': '1 Gbps Public & Private Network Uplinks', + 'nextInvoiceTotalRecurringAmount': 1 + }, + { + 'categoryCode': 'public_port', + 'description': '1 Gbps Public Uplink', + 'nextInvoiceTotalRecurringAmount': 1 + }, + { + 'categoryCode': 'service_port', + 'description': '1 Gbps Private Uplink', + 'nextInvoiceTotalRecurringAmount': 1 + } ], 'package': { "id": 835, diff --git a/SoftLayer/managers/vs.py b/SoftLayer/managers/vs.py index 77410ff4a..75c00127a 100644 --- a/SoftLayer/managers/vs.py +++ b/SoftLayer/managers/vs.py @@ -245,7 +245,7 @@ def get_instance(self, instance_id, **kwargs): 'userData,' '''billingItem[id,nextInvoiceTotalRecurringAmount, package[id,keyName], - children[categoryCode,nextInvoiceTotalRecurringAmount], + children[description,categoryCode,nextInvoiceTotalRecurringAmount], orderItem[id, order.userRecord[username], preset.keyName]],''' diff --git a/tests/CLI/modules/vs/vs_tests.py b/tests/CLI/modules/vs/vs_tests.py index 892a823fd..29007f154 100644 --- a/tests/CLI/modules/vs/vs_tests.py +++ b/tests/CLI/modules/vs/vs_tests.py @@ -323,7 +323,7 @@ def test_create_options_prices(self): def test_create_options_prices_location(self): result = self.run_command(['vs', 'create-options', '--prices', 'dal13', - '--vsi-type', 'TRANSIENT_CLOUD_SERVER']) + '--vsi-type', 'TRANSIENT_CLOUD_SERVER']) self.assert_no_fail(result) @mock.patch('SoftLayer.CLI.formatting.confirm') @@ -345,19 +345,19 @@ def test_dns_sync_both(self, confirm_mock): 'getResourceRecords') getResourceRecords.return_value = [] createAargs = ({ - 'type': 'a', - 'host': 'vs-test1', - 'domainId': 12345, # from SoftLayer_Account::getDomains - 'data': '172.16.240.2', - 'ttl': 7200 - },) + 'type': 'a', + 'host': 'vs-test1', + 'domainId': 12345, # from SoftLayer_Account::getDomains + 'data': '172.16.240.2', + 'ttl': 7200 + },) createPTRargs = ({ - 'type': 'ptr', - 'host': '2', - 'domainId': 123456, - 'data': 'vs-test1.test.sftlyr.ws', - 'ttl': 7200 - },) + 'type': 'ptr', + 'host': '2', + 'domainId': 123456, + 'data': 'vs-test1.test.sftlyr.ws', + 'ttl': 7200 + },) result = self.run_command(['vs', 'dns-sync', '100']) @@ -400,12 +400,12 @@ def test_dns_sync_v6(self, confirm_mock): } } createV6args = ({ - 'type': 'aaaa', - 'host': 'vs-test1', - 'domainId': 12345, - 'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004', - 'ttl': 7200 - },) + 'type': 'aaaa', + 'host': 'vs-test1', + 'domainId': 12345, + 'data': '2607:f0d0:1b01:0023:0000:0000:0000:0004', + 'ttl': 7200 + },) guest.return_value = test_guest result = self.run_command(['vs', 'dns-sync', '--aaaa-record', '100']) self.assert_no_fail(result) @@ -820,11 +820,11 @@ def test_billing(self): 'Recurring Fee': None, 'Total': 1.54, 'prices': [ - {'Recurring Price': 1}, - {'Recurring Price': 1}, - {'Recurring Price': 1}, - {'Recurring Price': 1}, - {'Recurring Price': 1} + {'description': '1 GB', 'Recurring Price': 1}, + {'description': 'Reboot / Remote Console', 'Recurring Price': 1}, + {'description': '1 Gbps Public & Private Network Uplinks', 'Recurring Price': 1}, + {'description': '1 Gbps Public Uplink', 'Recurring Price': 1}, + {'description': '1 Gbps Private Uplink', 'Recurring Price': 1} ] } self.assert_no_fail(result) From f6677a7fedafc9c14e58eebdd84dbde064103be8 Mon Sep 17 00:00:00 2001 From: caberos Date: Fri, 12 Nov 2021 14:50:49 -0400 Subject: [PATCH 2/2] fix the team code review --- SoftLayer/CLI/virt/billing.py | 2 +- tests/CLI/modules/vs/vs_tests.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SoftLayer/CLI/virt/billing.py b/SoftLayer/CLI/virt/billing.py index ddc785361..7ef1e0884 100644 --- a/SoftLayer/CLI/virt/billing.py +++ b/SoftLayer/CLI/virt/billing.py @@ -30,7 +30,7 @@ def cli(env, identifier): table.add_row(['Total', utils.lookup(result, 'billingItem', 'nextInvoiceTotalRecurringAmount')]) table.add_row(['Provision Date', utils.lookup(result, 'provisionDate')]) - price_table = formatting.Table(['description', 'Recurring Price']) + price_table = formatting.Table(['Description', 'Recurring Price']) for item in utils.lookup(result, 'billingItem', 'children') or []: price_table.add_row([item['description'], item['nextInvoiceTotalRecurringAmount']]) diff --git a/tests/CLI/modules/vs/vs_tests.py b/tests/CLI/modules/vs/vs_tests.py index 29007f154..187445063 100644 --- a/tests/CLI/modules/vs/vs_tests.py +++ b/tests/CLI/modules/vs/vs_tests.py @@ -820,11 +820,11 @@ def test_billing(self): 'Recurring Fee': None, 'Total': 1.54, 'prices': [ - {'description': '1 GB', 'Recurring Price': 1}, - {'description': 'Reboot / Remote Console', 'Recurring Price': 1}, - {'description': '1 Gbps Public & Private Network Uplinks', 'Recurring Price': 1}, - {'description': '1 Gbps Public Uplink', 'Recurring Price': 1}, - {'description': '1 Gbps Private Uplink', 'Recurring Price': 1} + {'Description': '1 GB', 'Recurring Price': 1}, + {'Description': 'Reboot / Remote Console', 'Recurring Price': 1}, + {'Description': '1 Gbps Public & Private Network Uplinks', 'Recurring Price': 1}, + {'Description': '1 Gbps Public Uplink', 'Recurring Price': 1}, + {'Description': '1 Gbps Private Uplink', 'Recurring Price': 1} ] } self.assert_no_fail(result)