def test_default_viewname_overrides_fti(self): response = HTTPResponse() environment = { 'URL': '', 'PARENTS': [self.site], 'REQUEST_METHOD': 'GET', 'SERVER_PORT': '80', 'REQUEST_METHOD': 'GET', 'steps': [], 'SERVER_NAME': 'localhost', '_hacked_path': 0 } r = HTTPRequest(StringIO(), environment, response) r.other.update(environment) # we define a Zope3-style default view name for which a view # actually exists defineDefaultViewName('index.html', IDummyContent) try: from zope.component import provideAdapter provideAdapter(DummyView, (DummyContent, IBrowserRequest), IBrowserView, 'index.html') except ImportError: # BBB for Zope 2.8 from zope.app.tests import ztapi ztapi.browserView(IDummyContent, 'index.html', DummyView) r.traverse('foo') self.assertEqual( r.URL, '/foo/index.html' ) self.assertEqual( r.response.base, '/foo/' )
def test_default_viewname_overrides_fti(self): response = HTTPResponse() environment = { 'URL': '', 'PARENTS': [self.site], 'REQUEST_METHOD': 'GET', 'SERVER_PORT': '80', 'REQUEST_METHOD': 'GET', 'steps': [], 'SERVER_NAME': 'localhost', '_hacked_path': 0 } r = HTTPRequest(StringIO(), environment, response) r.other.update(environment) alsoProvides(r, IBrowserRequest) # we define a Zope3-style default view name for which a view # actually exists defineDefaultViewName('index.html', DummyContent) provideAdapter(DummyView, (DummyContent, IBrowserRequest), IBrowserView, 'index.html') r.traverse('foo') self.assertEqual(r.URL, '/foo/index.html') self.assertEqual(r.response.base, '/foo/')
def makeRequest(self): response = HTTPResponse() request = HTTPRequest(StringIO(''), test_environ.copy(), response) # Set up request.form, etc. request.processInputs() # Make sure the URLs are set up correctly by faking traversal root = DummyObject() root.john = DummyObject() root.john.mc = DummyObject() root.john.mc.clane = DummyObject() request['PARENTS'] = [root] request.traverse(request['PATH_INFO']) return request
def test_default_view_from_fti(self): response = HTTPResponse() environment = { 'URL': '', 'PARENTS': [self.site], 'REQUEST_METHOD': 'GET', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '80', 'REQUEST_METHOD': 'GET', 'steps': [], '_hacked_path': 0} r = HTTPRequest(StringIO(), environment, response) r.other.update(environment) r.traverse('foo') self.assertEqual( r.URL, '/foo/dummy_view' ) self.assertEqual( r.response.base, '/foo/', 'CMF Collector issue #192 (wrong base): %s' % (r.response.base or 'empty',) )
def test_default_view_from_fti(self): response = HTTPResponse() environment = { 'URL': '', 'PARENTS': [self.site], 'REQUEST_METHOD': 'GET', 'SERVER_PORT': '80', 'REQUEST_METHOD': 'GET', 'steps': [], 'SERVER_NAME': 'localhost', '_hacked_path': 0 } r = HTTPRequest(StringIO(), environment, response) r.other.update(environment) r.traverse('foo') self.assertEqual( r.URL, '/foo/dummy_view' ) self.assertEqual( r.response.base, '/foo/', 'CMF Collector issue #192 (wrong base): %s' % (r.response.base or 'empty',) )
def test_default_viewname_but_no_view_doesnt_override_fti(self): response = HTTPResponse() environment = { 'URL': '', 'PARENTS': [self.site], 'REQUEST_METHOD': 'GET', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '80', 'REQUEST_METHOD': 'GET', 'steps': [], '_hacked_path': 0 } r = HTTPRequest(StringIO(), environment, response) r.other.update(environment) # we define a Zope3-style default view name, but no # corresponding view, no change in behaviour expected defineDefaultViewName('index.html', IDummyContent) r.traverse('foo') self.assertEqual( r.URL, '/foo/dummy_view' ) self.assertEqual( r.response.base, '/foo/' )
def test_default_viewname_but_no_view_doesnt_override_fti(self): response = HTTPResponse() environment = { 'URL': '', 'PARENTS': [self.site], 'REQUEST_METHOD': 'GET', 'SERVER_PORT': '80', 'REQUEST_METHOD': 'GET', 'steps': [], 'SERVER_NAME': 'localhost', '_hacked_path': 0 } r = HTTPRequest(StringIO(), environment, response) r.other.update(environment) # we define a Zope3-style default view name, but no # corresponding view, no change in behaviour expected defineDefaultViewName('index.html', DummyContent) r.traverse('foo') self.assertEqual( r.URL, '/foo/dummy_view' ) self.assertEqual( r.response.base, '/foo/' )