Merge "Fix request version returns value handling error."

This commit is contained in:
Zuul 2018-02-23 08:33:17 +00:00 committed by Gerrit Code Review
commit 0497baa83d
4 changed files with 34 additions and 14 deletions

View File

@ -55,11 +55,18 @@ class TestPolicyTypeList(TestPolicyType):
def test_policy_type_list(self):
arglist = []
parsed_args = self.check_parser(self.cmd, arglist, [])
expected_columns = self.expected_columns
expected_rows = self.expected_rows
columns, rows = self.cmd.take_action(parsed_args)
if len(columns) == 2:
expected_columns = ['name', 'version']
expected_rows = [
('CCC', '1.0')
]
self.mock_client.policy_types.assert_called_with()
self.assertEqual(self.expected_columns, columns)
self.assertEqual(self.expected_rows, rows)
self.assertEqual(expected_columns, columns)
self.assertEqual(expected_rows, rows)
class TestPolicyTypeShow(TestPolicyType):

View File

@ -55,6 +55,11 @@ class TestProfileTypeList(TestProfileType):
expected_columns = ['name', 'version', 'support_status']
columns, rows = self.cmd.take_action(parsed_args)
if len(columns) == 2:
expected_columns = ['name', 'version']
expected_rows = [
('CCC', '1.0')
]
self.mock_client.profile_types.assert_called_with()
self.assertEqual(expected_columns, columns)

View File

@ -38,13 +38,17 @@ class PolicyTypeList(command.Lister):
columns = ['name', 'version', 'support_status']
results = []
for t in types:
for v in t.support_status.keys():
st_list = '\n'.join([
' since '.join((item['status'], item['since']))
for item in t.support_status[v]
])
if t.support_status:
for v in t.support_status.keys():
st_list = '\n'.join([
' since '.join((item['status'], item['since']))
for item in t.support_status[v]
])
results.append((t.name, v, st_list))
results.append((t.name, v, st_list))
else:
columns = ['name', 'version']
results.append((t.name.split('-')[0], t.name.split('-')[1]))
return columns, sorted(results)

View File

@ -39,13 +39,17 @@ class ProfileTypeList(command.Lister):
results = []
for t in types:
for v in t.support_status.keys():
st_list = '\n'.join([
' since '.join((item['status'], item['since']))
for item in t.support_status[v]
])
if t.support_status:
for v in t.support_status.keys():
st_list = '\n'.join([
' since '.join((item['status'], item['since']))
for item in t.support_status[v]
])
results.append((t.name, v, st_list))
results.append((t.name, v, st_list))
else:
columns = ['name', 'version']
results.append((t.name.split('-')[0], t.name.split('-')[1]))
return columns, sorted(results)