[FIX] root dispatcher should raise a 404 error when a controller is not found
bzr revid: xmo@openerp.com-20110321162904-33ai6lqaty0unhro
This commit is contained in:
@@ -265,7 +265,7 @@ class Root(object):
|
||||
if getattr(m, 'exposed', 0):
|
||||
print "Calling", ps, c, meth, m
|
||||
return m(**kw)
|
||||
|
||||
raise cherrypy.NotFound('/' + '/'.join(l))
|
||||
else:
|
||||
raise cherrypy.HTTPRedirect('/base/static/openerp/base.html', 301)
|
||||
default.exposed = True
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import cherrypy
|
||||
import mock
|
||||
import unittest2
|
||||
import openerpweb.openerpweb
|
||||
@@ -18,3 +19,20 @@ class OpenERPModelTest(unittest2.TestCase):
|
||||
Model.read([42])
|
||||
session.execute.assert_called_once_with(
|
||||
'a.b', 'read', [42])
|
||||
|
||||
class DispatcherTest(unittest2.case.TestCase):
|
||||
def test_default_redirect(self):
|
||||
self.assertRaises(
|
||||
cherrypy.HTTPRedirect,
|
||||
openerpweb.openerpweb.Root().default)
|
||||
def test_serve_static_missing(self):
|
||||
self.assertRaises(
|
||||
cherrypy.NotFound,
|
||||
openerpweb.openerpweb.Root().default,
|
||||
'does-not-exist', 'static', 'bar')
|
||||
def test_serve_controller_missing(self):
|
||||
self.assertRaises(
|
||||
cherrypy.NotFound,
|
||||
openerpweb.openerpweb.Root().default,
|
||||
'controller', 'does', 'not', 'exist')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user