How to use the falcon.Request function in falcon

To help you get started, we’ve selected a few falcon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github softlayer / jumpgate / tests / jumpgate-tests / compute / test_volumes.py View on Github external
def perform_get_vol_details(self, tenant_id, instance_id, volume_id):
        self.client, self.env = get_client_env()
        self.vg_clientMock = self.client['Virtual_Guest']
        self.vdi_clientMock = self.client['Virtual_Disk_Image']
        self.req = falcon.Request(self.env)
        self.resp = falcon.Response()
        instance = volumes.OSVolumeAttachmentV2()
        instance.on_get(self.req, self.resp, tenant_id,
                           instance_id, volume_id)
github projectatomic / commissaire-mvp / test / test_authenticator_httpbasicauth.py View on Github external
def expect_forbidden(self, data=None, cn=None):
        auth = httpauthclientcert.HTTPClientCertAuth(cn=cn)
        req = falcon.Request(create_environ())
        if data is not None:
            req.env[SSL_CLIENT_VERIFY] = data

        resp = falcon.Response()
        self.assertRaises(
            falcon.HTTPForbidden,
            auth.authenticate,
            req, resp)
github softlayer / jumpgate / tests / jumpgate-tests / compute / test_volumes.py View on Github external
def test_on_post_fail_vdi_client_exception(self):
        body_str = ('{"volumeAttachment": '
                    '{"device": null, "volumeId": "3887490"}}')
        client, env = get_client_env(body=body_str)
        vg_clientMock = client['Virtual_Guest']
        vdi_clientMock = client['Virtual_Disk_Image']
        vdi_clientMock.getObject.side_effect = Exception('No Object!')
        req = falcon.Request(env)
        resp = falcon.Response()
        instance = volumes.OSVolumeAttachmentsV2()
        instance.on_post(req, resp, TENANT_ID, INSTANCE_ID)
        self.assertEquals(resp.body, {'volumeFault':
                                      {'message':
                                       'No Object!',
                                       'code': '400'}})
github softlayer / jumpgate / tests / jumpgate-tests / compute / test_servers.py View on Github external
def test_on_post_invalid_create(self, create_instance_mock):
        create_instance_mock.side_effect = Exception('badrequest')
        client, env = get_client_env(body=self.body_string)
        req = falcon.Request(env)
        resp = falcon.Response()
        self.instance.on_post(req, resp, 'tenant_id')
        self.assertEqual(resp.status, 400)
github falconry / falcon / tests / test_headers.py View on Github external
def test_headers_as_list(self, client):
        headers = [
            ('Client-ID', '692ba466-74bb-11e3-bf3f-7567c531c7ca'),
            ('Accept', 'audio/*; q=0.2, audio/basic')
        ]

        # Unit test
        environ = testing.create_environ(headers=headers)
        req = falcon.Request(environ)

        for name, value in headers:
            assert (name.upper(), value) in req.headers.items()

        # Functional test
        client.app.add_route('/', testing.SimpleTestResource(headers=headers))
        result = client.simulate_get()

        for name, value in headers:
            assert result.headers[name] == value
github softlayer / jumpgate / tests / jumpgate-tests / compute / test_flavors.py View on Github external
def perform_flavor_detail(self, q_str, tenant_id, flavor_list):
        env = get_client_env(query_string=q_str)
        self.req = falcon.Request(env)
        self.resp = falcon.Response()
        self.app = mock.MagicMock()
        instance = flavors.FlavorsDetailV2(app=self.app, flavors=flavor_list)
        instance.on_get(self.req, self.resp, tenant_id)
github falconry / falcon / tests / test_cookies.py View on Github external
def test_cookie_header_is_missing():
    environ = testing.create_environ(headers={})

    req = falcon.Request(environ)
    assert req.cookies == {}
    assert req.get_cookie_values('x') is None

    # NOTE(kgriffs): Test again with a new object to cover calling in the
    #   opposite order.
    req = falcon.Request(environ)
    assert req.get_cookie_values('x') is None
    assert req.cookies == {}
github softlayer / jumpgate / tests / jumpgate-tests / compute / test_extra_specs.py View on Github external
def perform_extra_detail(self, tenant_id, flavor_id):
        env = get_client_env()
        self.req = falcon.Request(env)
        self.resp = falcon.Response()
        flavors = flavor_list_loader.Flavors.get_flavors(app=mock.MagicMock())
        instance = extra_specs.ExtraSpecsFlavorV2(app=mock.MagicMock(),
                                                  flavors=flavors)
        instance.on_get(self.req, self.resp, tenant_id, flavor_id)
github softlayer / jumpgate / tests / jumpgate-tests / compute / test_volumes.py View on Github external
def perform_attach_action(self, body_str, tenant_id, instance_id):
        self.client, self.env = get_client_env(body=body_str)
        self.vg_clientMock = self.client['Virtual_Guest']
        self.vdi_clientMock = self.client['Virtual_Disk_Image']
        self.req = falcon.Request(self.env)
        self.resp = falcon.Response()
        instance = volumes.OSVolumeAttachmentsV2()
        instance.on_post(self.req, self.resp, tenant_id, instance_id)