Merge "Correct a misuse of RestController in the Event API"

This commit is contained in:
Jenkins
2014-01-31 11:08:56 +00:00
committed by Gerrit Code Review
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)