Skip to content

Commit f870548

Browse files
committed
Refactor network fakes to sdk properties PART 5
Included resources: qos_policy qos_rule qos_rule_type Note: Parameters in unittests was modified for compatibility with sdk Change-Id: Iaa902d64ff1b29a07c28ed2100d437da506be475
1 parent 30aa27b commit f870548

11 files changed

Lines changed: 345 additions & 463 deletions

File tree

openstackclient/network/v2/network_qos_rule.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474

7575
def _get_columns(item):
76-
hidden_columns = ['location', 'tenant_id']
76+
hidden_columns = ['location', 'name', 'tenant_id']
7777
return utils.get_osc_show_columns_for_sdk_resource(
7878
item, {}, hidden_columns
7979
)
@@ -148,14 +148,6 @@ def _get_attrs(network_client, parsed_args, is_create=False):
148148
return attrs
149149

150150

151-
def _get_item_properties(item, fields):
152-
"""Return a tuple containing the item properties."""
153-
row = []
154-
for field in fields:
155-
row.append(item.get(field, ''))
156-
return tuple(row)
157-
158-
159151
def _rule_action_call(client, action, rule_type):
160152
rule_type = rule_type.replace('-', '_')
161153
func_name = f'{action}_qos_{rule_type}_rule'
@@ -357,10 +349,10 @@ def take_action(self, parsed_args):
357349
qos = client.find_qos_policy(
358350
parsed_args.qos_policy, ignore_missing=False
359351
)
360-
data = qos.rules
352+
361353
return (
362354
column_headers,
363-
(_get_item_properties(s, columns) for s in data),
355+
(utils.get_dict_properties(s, columns) for s in qos.rules),
364356
)
365357

366358

openstackclient/tests/functional/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ def openstack(
9797
)
9898

9999
if parse_output:
100-
return json.loads(output)
100+
try:
101+
return json.loads(output)
102+
except json.JSONDecodeError:
103+
print(f'failed to decode: {output}')
104+
raise
101105
else:
102106
return output
103107

0 commit comments

Comments
 (0)