def _app(self): '''Returns the app object for a test.''' app = Zope2.app(Zope2.sandbox().open()) AppZapper().set(app) app = utils.makerequest(app) connections.register(app) return app
def afterSetUp(self): name = 'mock' new_environ = { 'PATH_INFO': '/' + name, '_stdout': StringIO(), } # root is an aquisition wrapper over app and REQUEST, as if REQUEST agreggates app # some tests use app.REQUEST and some use root self.root = makerequest(self.app, new_environ['_stdout'], new_environ) self.app.REQUEST = self.root.REQUEST self.app.REQUEST.AUTHENTICATED_USER = Mock() self.app.REQUEST.AUTHENTICATED_USER.getUserName.return_value = 'gigel' self.root.standard_html_header = '' self.root.standard_html_footer = '' self.root.management_page_charset = 'utf-8' self.root.buttons_loginout = '' self.root.buttons_py = '' dropdown = open(self.get_abs_path('data/dropdownmenus.txt', globals()),'rb') self.root.manage_addFile(id='dropdownmenus.txt', file=dropdown) dropdown.close() self.root['breadcrumb'] = PageTemplateFile('data/breadcrumb.pt', globals()) self.root['standard_template.pt'] = PageTemplateFile('data/standard_template.pt', globals()) self.engine = self.create_reportek_engine(self.root) self.wf = self.create_flow_engine(self.root)
def mock_request(self): request = BaseTest.create_mock_request() self.root = makerequest(self._plain_root, StringIO()) request = self.root.REQUEST request.AUTHENTICATED_USER = Mock() response = request.RESPONSE response._data = StringIO() response.write = response._data.write return request
def app(): """Opens a ZODB connection and returns the app object.""" app = Zope2.app() app = utils.makerequest(app) connections.register(app) return app
def app(): '''Opens a ZODB connection and returns the app object.''' app = Zope2.app() app = utils.makerequest(app) connections.register(app) return app