示例#1
0
    def assertResponse(self,
                       app,
                       method,
                       url,
                       status=None,
                       headers=None,
                       content=None):
        host, port = 'localhost', 80
        http_client_intercept.install()
        add_wsgi_intercept(host, port, app)
        client = http_lib.HTTPConnection(host, port)
        client.request(method, url)
        response = client.getresponse()

        if status is not None:
            self.assertEqual(response.status, status)

        headers = headers or {}
        for k, v in headers.items():
            self.assertEqual(response.getheader(k), v)

        if content is not None:
            self.assertEqual(response.read(), content)

        client.close()
        remove_wsgi_intercept(host, port)
        http_client_intercept.uninstall()
def run_fake_magnetodb_api(past_conf_file, magneto_conf_file):
    from magnetodb.openstack.common import pastedeploy

    config.parse_args(argv=[],
                      default_config_files=[magneto_conf_file])

    http_client_intercept.install()

    app = pastedeploy.paste_deploy_app(past_conf_file, PROJECT_NAME, {})
    wsgi_intercept.add_wsgi_intercept(CONF.bind_host,
                                      CONF.bind_port,
                                      lambda: app)
示例#3
0
文件: base.py 项目: smurfix/pybble
	def setupRest(self):
		from pybble.app import make_cfg_app
		super(WebTC,self).setupRest()
		global main_app
		app = make_cfg_app()
		main_app = SubdomainDispatcher(app)

		if not skip_httpclient:
			http_client_intercept.install()
		if not skip_httplib2:
			httplib2_intercept.install()
		if not skip_requests:
			requests_intercept.install()
		if not skip_urllib:
			urllib_intercept.install_opener()
示例#4
0
 def setUp(self):
     http_client_intercept.install()
     wsgi_intercept.add_wsgi_intercept('statictest', 80, self.get_app)
示例#5
0
 def setUp(self):
     http_client_intercept.install()
     wsgi_intercept.add_wsgi_intercept('statictest', 80, self.get_app)
def run_fake_magnetodb_api():
    http_client_intercept.install()
    app = deploy.loadapp("config:{}".format(PASTE_CONFIG_FILE))
    wsgi_intercept.add_wsgi_intercept("localhost", 8080, lambda: app)
示例#7
0
def http_install(port=80):
    http_client_intercept.install()
    wsgi_intercept.add_wsgi_intercept('some_hopefully_nonexistant_domain',
                                      port, wsgi_app.create_fn)
def http_install(port=80):
    http_client_intercept.install()
    wsgi_intercept.add_wsgi_intercept("some_hopefully_nonexistant_domain", port, wsgi_app.create_fn)
def http_install(port=80):
    _saved_debuglevel, wsgi_intercept.debuglevel = wsgi_intercept.debuglevel, 1
    http_client_intercept.install()
    wsgi_intercept.add_wsgi_intercept('some_hopefully_nonexistant_domain',
                                      port, wsgi_app.create_fn)
def http_install(port=80):
    _saved_debuglevel, wsgi_intercept.debuglevel = wsgi_intercept.debuglevel, 1
    http_client_intercept.install()
    wsgi_intercept.add_wsgi_intercept(
            'some_hopefully_nonexistant_domain', port, wsgi_app.create_fn)
示例#11
0
def run_fake_magnetodb_api(paste_conf_file, app_name=None):
    from magnetodb.openstack.common import pastedeploy

    http_client_intercept.install()
    app = pastedeploy.paste_deploy_app(paste_conf_file, app_name, {})
    wsgi_intercept.add_wsgi_intercept("localhost", 8080, lambda: app)