Merge "Add "event trait description" command"

changes/41/465141/1
Jenkins 6 years ago committed by Gerrit Code Review
commit 31e71816c4
  1. 21
      pankoclient/osc/v2/events.py
  2. 2
      pankoclient/tests/unit/fakes.py
  3. 19
      pankoclient/tests/unit/osc/v2/test_events.py
  4. 2
      pankoclient/v2/client.py
  5. 12
      pankoclient/v2/events.py
  6. 1
      setup.cfg

@ -131,3 +131,24 @@ class EventTraitList(command.Lister):
columns = ('name', 'value', 'type')
return (columns,
(utils.get_item_properties(t, columns) for t in event_traits))
class EventTraitDescription(command.Lister):
"""List trait info for an event type."""
def get_parser(self, prog_name):
parser = super(EventTraitDescription, self).get_parser(prog_name)
parser.add_argument(
'type_name',
metavar='<EVENT_TYPE>',
help='Type of the event for which traits definitions will be '
'shown.'
)
return parser
def take_action(self, parsed_args):
ac = self.app.client_manager.event
event_traits = ac.event_trait_description.list(parsed_args.type_name)
columns = ('name', 'type')
return (columns,
(utils.get_item_properties(t, columns) for t in event_traits))

@ -59,6 +59,8 @@ class FakeTestEventV2Client(object):
self.fake_http_client)
self.event_type = events.EventTypeManager(self.fake_http_client)
self.event_trait = events.EventTraitsManager(self.fake_http_client)
self.event_trait_description = events.EventTraitDescriptionManager(
self.fake_http_client)
class FakeHTTPClient(object):

@ -54,3 +54,22 @@ class TestEventTraitsList(test_base.TestEventV2):
expected_url = '/v2/event_types/%s/traits/%s' % (
parsed_args.type_name, parsed_args.trait_name)
mock_list.assert_called_once_with(expected_url)
@mock.patch.object(events_mgr.EventTraitDescriptionManager, '_list')
class TestEventTraitDescription(test_base.TestEventV2):
def setUp(self):
super(TestEventTraitDescription, self).setUp()
self.cmd = events.EventTraitDescription(self.app, None)
def test_event_type_traits_description(self, mock_list):
arglist = [
'event_type1',
]
verifylist = [
('type_name', 'event_type1'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
expected_url = '/v2/event_types/%s/traits/' % parsed_args.type_name
mock_list.assert_called_once_with(expected_url)

@ -28,3 +28,5 @@ class Client(object):
self.event = events.EventManager(self.http_client)
self.event_type = events.EventTypeManager(self.http_client)
self.event_trait = events.EventTraitsManager(self.http_client)
self.event_trait_description = events.EventTraitDescriptionManager(
self.http_client)

@ -27,6 +27,10 @@ class EventTrait(base.Resource):
pass
class TraitDescription(base.Resource):
pass
class EventManager(base.ManagerWithFind):
resource_class = Event
@ -75,3 +79,11 @@ class EventTraitsManager(base.ManagerWithFind):
def list(self, event_type, trait_name):
url = '/v2/event_types/%s/traits/%s' % (event_type, trait_name)
return self._list(url)
class EventTraitDescriptionManager(base.ManagerWithFind):
resource_class = TraitDescription
def list(self, event_type):
url = '/v2/event_types/%s/traits/' % event_type
return self._list(url)

@ -35,6 +35,7 @@ openstack.event.v2 =
event show = pankoclient.osc.v2.events:EventShow
event type list = pankoclient.osc.v2.events:EventTypeList
event trait list = pankoclient.osc.v2.events:EventTraitList
event trait description = pankoclient.osc.v2.events:EventTraitDescription
[build_sphinx]
source-dir = doc/source

Loading…
Cancel
Save