Controllers that return `None` should be an HTTP 204.

This commit is contained in:
Ryan Petrello 2016-07-22 16:12:42 -04:00
parent 53eeda946d
commit fbcc2c27f7
2 changed files with 25 additions and 0 deletions

View File

@ -417,6 +417,8 @@ class PecanBase(object):
self.default_renderer,
self.template_path
)
if namespace is None:
return None
return renderer.render(template, namespace)
def find_controller(self, state):

View File

@ -2001,6 +2001,29 @@ class TestEngines(PecanTestCase):
assert r.status_int == 200
assert r.body == b_("Bill")
def test_template_with_no_namespace(self):
class RootController(object):
@expose('mako:mako.html')
def index(self):
return None
app = TestApp(Pecan(
RootController(),
template_path=self.template_path
))
r = app.get('/')
self.assertEqual(r.status_int, 204)
def test_json_with_no_namespace(self):
class RootController(object):
@expose('json')
def index(self):
return None
app = TestApp(Pecan(RootController()))
r = app.get('/')
self.assertEqual(r.status_int, 204)
class TestDeprecatedRouteMethod(PecanTestCase):