def __init__(self, connectionDetails): ''' Constructor ''' RequestHandler.__init__(self, connectionDetails) self.__client = paramiko.SSHClient() self.__client.load_system_host_keys() self.__client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
def test_get_api_page(self): T.MockedSettings['api_app'] = {'port': 8043, 'servername': 'push.test.com'} with mock.patch.dict(Settings, T.MockedSettings): T.assert_equal( RequestHandler.get_api_page("pushes"), "http://push.test.com:8043/api/pushes" )
class TemplateTestCase(T.TestCase): """Bare minimum setup to render and test templates""" __test__ = False authenticated = False @T.setup def setup_servlet(self): application = turtle.Turtle() application.settings = { "static_path": os.path.join(os.path.dirname(__file__), "../static"), "template_path": os.path.join(os.path.dirname(__file__), "../templates"), "autoescape": None, } # Properly load ui_modules and ui_methods application.ui_modules = {} application.ui_methods = {} application._load_ui_modules = types.MethodType(tornado.web.Application._load_ui_modules.im_func, application) application._load_ui_methods = types.MethodType(tornado.web.Application._load_ui_methods.im_func, application) application._load_ui_modules(ui_modules) application._load_ui_methods(ui_methods) if self.authenticated: application.settings["cookie_secret"] = "cookie_secret" request = turtle.Turtle() self.servlet = RequestHandler(application, request) def render_etree(self, page, *args, **kwargs): self.servlet.render(page, *args, **kwargs) rendered_page = "".join(self.servlet._write_buffer) tree = etree.HTML(rendered_page) return tree @contextmanager def no_ui_modules(self): modules = mock.Mock() modules.Request = mock.Mock() modules.NewRequestDialog = mock.Mock() with mock.patch.dict(self.servlet.ui, modules=modules): yield
def setup_servlet(self): application = turtle.Turtle() application.settings = { 'static_path': os.path.join(os.path.dirname(__file__), "../static"), 'template_path': os.path.join(os.path.dirname(__file__), "../templates"), 'autoescape': None, } # Properly load ui_modules and ui_methods application.ui_modules = {} application.ui_methods = {} application._load_ui_modules = types.MethodType(tornado.web.Application._load_ui_modules.im_func, application) application._load_ui_methods = types.MethodType(tornado.web.Application._load_ui_methods.im_func, application) application._load_ui_modules(ui_modules) application._load_ui_methods(ui_methods) if self.authenticated: application.settings['cookie_secret'] = 'cookie_secret' request = turtle.Turtle() self.servlet = RequestHandler(application, request)
def __init__(self, connectionDetails, webhdfsrequests): ''' Constructor ''' RequestHandler.__init__(self, connectionDetails) self.__webhdfsrequests = webhdfsrequests
def application(variables, start_response): request_handler = RequestHandler(variables) status, headers, body = request_handler.get_response() start_response(status, headers) return body
def __init__(self, connectionDetails): ''' Constructor ''' RequestHandler.__init__(self, connectionDetails)