Skip to main content

Pytest helpers for Falcon.

Project description

# Pytest-Falcon

Pytest helpers for the Falcon framework.

**WARNING WORK IN PROGRESS**


## Install

No pypi release yet.

```
pip install git+http://github.com/yohanboniface/pytest-falcon
```


## Usage

You must create an `app` fixture to expose the Falcon application you want to test:

```python
import falcon
import pytest


application = falcon.API()

@pytest.fixture
def app():
return application
```

## Fixtures

### client

Allows you to test your API:

```python
class Resource:

def on_post(self, req, resp, **kwargs):
resp.body = json.dumps(req.params)

application.add_route('/route', Resource())

def test_post(client):
resp = client.post('/route', {'myparam': 'myvalue'})
assert resp.status == falcon.HTTP_OK
assert resp.json['myparam'] == 'myvalue'
```

Response properties:
- `body` the body as `str`
- `json` the body parsed as json when the response content-type is 'application/json'
- `headers` the response headers
- `status` the response status, as `str` ('200 OK', '405 Method Not Allowed'…)
- `status_code` the response status code, as `int` (200, 201…)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-falcon-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

pytest_falcon-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest-falcon-0.1.0.tar.gz.

File metadata

File hashes

Hashes for pytest-falcon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0797db5320fd62c797b8c55a5dfa4277230db83721c2e0f18c11930e2278659f
MD5 b94336251cceca2512fb71d9eb397b16
BLAKE2b-256 65887062d63851a34cfe5bb6665264c9300f31095d7cf09f3121b287860cce94

See more details on using hashes here.

File details

Details for the file pytest_falcon-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_falcon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d33f561da3cd4eeb1aa4fd5eefdf8ece71460d4023447c06b2cd526aab0f5ac
MD5 90d7c28edab375711a1177d7d5244690
BLAKE2b-256 c1f8b4d9696b745947dae5385d27cee46d7e92f010dd089aa923d7c12c314b5e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page