Skip to main content

Pytest helpers for Falcon.

Project description

[![Build Status](https://travis-ci.org/yohanboniface/pytest-falcon.svg?branch=master)](https://travis-ci.org/yohanboniface/pytest-falcon) [![Pypi version](https://img.shields.io/pypi/v/pytest-falcon.svg)](https://pypi-hypernode.com/pypi/pytest-falcon)

# Pytest-Falcon

Pytest helpers for the Falcon framework.


## Install

```
pip install 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.3.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distributions

pytest_falcon-0.3.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

pytest_falcon-0.3.3-py2-none-any.whl (6.0 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for pytest-falcon-0.3.3.tar.gz
Algorithm Hash digest
SHA256 2134d3dc70da05dccf7fb8b23540a2f919f1a6e26772167a94cdd5bb56137698
MD5 6f6a2b8c3b569afd50e4a4056a223317
BLAKE2b-256 eca3dd2afa359565f8ec2757446b782abc820d963c56f7f0718d7f2668964855

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_falcon-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 551022536682af24dbbceb71d26bfa4d562a21d344d77fe7422620e98c33b6a5
MD5 4afe95701195e3d9637d72340c5c7299
BLAKE2b-256 8574e85308c5e3271a44c3b8df39e95f42cf8fb6c1b8be619970cfa96f65f8d1

See more details on using hashes here.

File details

Details for the file pytest_falcon-0.3.3-py2-none-any.whl.

File metadata

File hashes

Hashes for pytest_falcon-0.3.3-py2-none-any.whl
Algorithm Hash digest
SHA256 67d6f2c31ccbd0dbb50f6abea71d8e3c21c61ca37336ff6c2bec3457b016186e
MD5 a5f6b1c30358f59ac4cceabc085e788c
BLAKE2b-256 21182339f468b2a3af22c8f1a37855b010de6731b43d16a6c5caffb022dafcad

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