[TEST] test normal inheritance of controllers

bzr revid: xmo@openerp.com-20130329141645-m70aitx3kv74yo97
This commit is contained in:
Xavier Morel 2013-03-29 15:16:45 +01:00
parent 17eaf9e92a
commit 23904b523a
1 changed files with 27 additions and 0 deletions

View File

@ -179,3 +179,30 @@ class TestDispatching(DispatchCleanup):
body, status, headers = self.client.post('/cat')
self.assertEqual('404 NOT FOUND', status)
def test_extend(self):
class CatController(http.Controller):
_cp_path = '/cat'
@http.httprequest
def index(self, req):
return '[%s]' % self.speak()
def speak(self):
return 'Yu ordered cheezburgerz,'
class DogController(CatController):
_cp_path = '/dog'
def speak(self):
return 'Woof woof woof woof'
self.app.load_addons()
body, status, headers = self.client.get('/cat')
self.assertEqual('200 OK', status)
self.assertEqual('[Yu ordered cheezburgerz,]', ''.join(body))
body, status, headers = self.client.get('/dog')
self.assertEqual('200 OK', status)
self.assertEqual('[Woof woof woof woof]', ''.join(body))