Correct a misuse of RestController in the Event API

When nested RestControllers exist, in order to determine which
arguments are associated with the parent resource, pecan looks at the
get_one() method signature in the parent controller.

TraitsController needs the EventTypesController.get_one method to exist in
order to properly pass the `event_type` identifier.

Change-Id: Ic1704c8f9c810ada4e22e8de75ef2511006e8d9d
This commit is contained in:
Ryan Petrello
2014-01-29 10:46:43 -05:00
parent a1f494da64
commit 4be513f267
2 changed files with 10 additions and 4 deletions

View File

@@ -1797,12 +1797,13 @@ class EventTypesController(rest.RestController):
traits = TraitsController()
# FIXME(herndon): due to a bug in pecan, making this method
# get_all instead of get will hide the traits subcontroller.
# https://bugs.launchpad.net/pecan/+bug/1262277
@pecan.expose()
def get_one(self, event_type):
pecan.abort(404)
@requires_admin
@wsme_pecan.wsexpose([unicode])
def get(self):
def get_all(self):
"""Get all event types.
"""
return list(pecan.request.storage_conn.get_event_types())

View File

@@ -84,6 +84,11 @@ class TestTraitAPI(EventTestBase):
self.assertEqual(4, len(data))
def test_get_event_invalid_path(self):
data = self.get_json('/event_types/trait_A/', headers=headers,
expect_errors=True)
self.assertEqual(404, data.status_int)
def test_get_traits_for_non_existent_event(self):
path = self.PATH % "NO_SUCH_EVENT_TYPE"
data = self.get_json(path, headers=headers)