summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--heatclient/osc/v1/event.py20
-rw-r--r--heatclient/tests/unit/osc/v1/test_event.py12
2 files changed, 23 insertions, 9 deletions
diff --git a/heatclient/osc/v1/event.py b/heatclient/osc/v1/event.py
index b577e94..8f25ea3 100644
--- a/heatclient/osc/v1/event.py
+++ b/heatclient/osc/v1/event.py
@@ -175,6 +175,20 @@ class ListEvent(command.Lister):
else:
nested_depth = 0
+ if parsed_args.sort:
+ sorts = []
+ sort_keys = []
+ for sort in parsed_args.sort:
+ if sort.startswith(":"):
+ sorts.append(":".join(["event_time", sort.lstrip(":")]))
+ else:
+ sorts.append(sort)
+ sort_keys.append(sort.split(":")[0])
+ kwargs['sort_keys'] = sort_keys
+
+ if ":" in parsed_args.sort[0]:
+ kwargs['sort_dir'] = parsed_args.sort[0].split(":")[1]
+
if parsed_args.follow:
if parsed_args.formatter != 'log':
msg = _('--follow can only be specified with --format log')
@@ -207,12 +221,6 @@ class ListEvent(command.Lister):
limit=parsed_args.limit)
if parsed_args.sort:
- sorts = []
- for sort in parsed_args.sort:
- if sort.startswith(":"):
- sorts.append(":".join(["event_time", sort.lstrip(":")]))
- else:
- sorts.append(sort)
events = utils.sort_items(events, ','.join(sorts))
if parsed_args.formatter == 'log':
diff --git a/heatclient/tests/unit/osc/v1/test_event.py b/heatclient/tests/unit/osc/v1/test_event.py
index 3c64b92..d7ecb60 100644
--- a/heatclient/tests/unit/osc/v1/test_event.py
+++ b/heatclient/tests/unit/osc/v1/test_event.py
@@ -194,7 +194,9 @@ class TestEventList(TestEvent):
mock_sort_items.assert_called_with(mock.ANY,
"resource_name:desc")
- self.event_client.list.assert_called_with(**self.defaults)
+ self.event_client.list.assert_called_with(
+ filters={}, resource_name=None, sort_dir='desc',
+ sort_keys=['resource_name'], stack_id='my_stack')
self.assertEqual(self.fields, columns)
@mock.patch('osc_lib.utils.sort_items')
@@ -209,7 +211,9 @@ class TestEventList(TestEvent):
mock_sort_items.assert_called_with(mock.ANY,
"resource_name:desc,id:asc")
- self.event_client.list.assert_called_with(**self.defaults)
+ self.event_client.list.assert_called_with(
+ filters={}, resource_name=None, sort_dir='desc',
+ sort_keys=['resource_name', 'id'], stack_id='my_stack')
self.assertEqual(self.fields, columns)
@mock.patch('osc_lib.utils.sort_items')
@@ -223,7 +227,9 @@ class TestEventList(TestEvent):
columns, data = self.cmd.take_action(parsed_args)
mock_sort_items.assert_called_with(mock.ANY, "event_time:desc")
- self.event_client.list.assert_called_with(**self.defaults)
+ self.event_client.list.assert_called_with(
+ filters={}, resource_name=None, sort_dir='desc', sort_keys=[],
+ stack_id='my_stack')
self.assertEqual(self.fields, columns)
@mock.patch('time.sleep')