Add support for "event type list" command
Change-Id: Ifa4c7ede4f7860e57f541e4a09422dca19381d08
This commit is contained in:
parent
c30ff62fd9
commit
9f0171fd13
|
@ -85,3 +85,12 @@ class EventShow(command.ShowOne):
|
|||
data = copy.deepcopy(event._info)
|
||||
data.update({'traits': json.dumps(data['traits'], indent=4)})
|
||||
return self.dict2columns(data)
|
||||
|
||||
|
||||
class EventTypeList(command.Lister):
|
||||
"""List event types"""
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
ac = self.app.client_manager.event
|
||||
event_types = ac.event_type.list()
|
||||
return ('Event Type',), ((t,)for t in event_types)
|
||||
|
|
|
@ -19,6 +19,7 @@ from requests import Response
|
|||
|
||||
from pankoclient.common import base
|
||||
from pankoclient.v2 import capabilities
|
||||
from pankoclient.v2 import events
|
||||
|
||||
|
||||
# fake request id
|
||||
|
@ -56,6 +57,7 @@ class FakeTestEventV2Client(object):
|
|||
self.fake_http_client = mock.Mock()
|
||||
self.capabilities = capabilities.CapabilitiesManager(
|
||||
self.fake_http_client)
|
||||
self.event_type = events.EventTypeManager(self.fake_http_client)
|
||||
|
||||
|
||||
class FakeHTTPClient(object):
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# Copyright 2017 Huawei, Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import mock
|
||||
|
||||
from pankoclient.osc.v2 import events
|
||||
from pankoclient.tests.unit import base as test_base
|
||||
from pankoclient.v2 import events as events_mgr
|
||||
|
||||
|
||||
@mock.patch.object(events_mgr.EventTypeManager, '_list')
|
||||
class TestEventTypeList(test_base.TestEventV2):
|
||||
def setUp(self):
|
||||
super(TestEventTypeList, self).setUp()
|
||||
self.cmd = events.EventTypeList(self.app, None)
|
||||
|
||||
def test_event_type_list(self, mock_list):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
mock_list.assert_called_once_with('/v2/event_types/')
|
|
@ -26,3 +26,4 @@ class Client(object):
|
|||
self.http_client = http._construct_http_client(*args, **kwargs)
|
||||
self.capabilities = capabilities.CapabilitiesManager(self.http_client)
|
||||
self.event = events.EventManager(self.http_client)
|
||||
self.event_type = events.EventTypeManager(self.http_client)
|
||||
|
|
|
@ -19,6 +19,10 @@ class Event(base.Resource):
|
|||
pass
|
||||
|
||||
|
||||
class EventType(base.Resource):
|
||||
pass
|
||||
|
||||
|
||||
class EventManager(base.ManagerWithFind):
|
||||
resource_class = Event
|
||||
|
||||
|
@ -51,3 +55,11 @@ class EventManager(base.ManagerWithFind):
|
|||
"""
|
||||
path = '/v2/events/%s'
|
||||
return self._get(path % message_id)
|
||||
|
||||
|
||||
class EventTypeManager(base.ManagerWithFind):
|
||||
resource_class = EventType
|
||||
|
||||
def list(self):
|
||||
url = '/v2/event_types/'
|
||||
return self._list(url)
|
||||
|
|
|
@ -33,6 +33,7 @@ openstack.event.v2 =
|
|||
event capabilities list = pankoclient.osc.v2.capabilities:CliCapabilitiesList
|
||||
event list = pankoclient.osc.v2.events:EventList
|
||||
event show = pankoclient.osc.v2.events:EventShow
|
||||
event type list = pankoclient.osc.v2.events:EventTypeList
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
|
|
Loading…
Reference in New Issue