pyramid_cubicweb/tests/test_core.py
author Christophe de Vienne <christophe@unlish.com>
Mon, 23 Feb 2015 17:17:43 +0100
changeset 11559 136dd873dca2
parent 11556 1eeba41a2e95
child 11568 a9940c6cd693
permissions -rw-r--r--
[login] Test the login views

from pyramid_cubicweb.tests import PyramidCWTest

from cubicweb.view import View
from cubicweb.web import Redirect


class Redirector(View):
    __regid__ = 'redirector'

    def call(self, rset=None):
        self._cw.set_header('Cache-Control', 'no-cache')
        raise Redirect('http://example.org')


class CoreTest(PyramidCWTest):
    anonymous_allowed = True

    def test_cw_to_pyramid_copy_headers_on_redirect(self):
        self.vreg.register(Redirector)
        try:
            res = self.webapp.get('/?vid=redirector', expect_errors=True)
            self.assertEqual(res.status_int, 303)
            self.assertEqual(res.headers['Cache-Control'], 'no-cache')
        finally:
            self.vreg.unregister(Redirector)