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…)
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
Release history Release notifications | RSS feed
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)
Built Distribution
File details
Details for the file pytest-falcon-0.1.0.tar.gz
.
File metadata
- Download URL: pytest-falcon-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0797db5320fd62c797b8c55a5dfa4277230db83721c2e0f18c11930e2278659f |
|
MD5 | b94336251cceca2512fb71d9eb397b16 |
|
BLAKE2b-256 | 65887062d63851a34cfe5bb6665264c9300f31095d7cf09f3121b287860cce94 |
File details
Details for the file pytest_falcon-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_falcon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d33f561da3cd4eeb1aa4fd5eefdf8ece71460d4023447c06b2cd526aab0f5ac |
|
MD5 | 90d7c28edab375711a1177d7d5244690 |
|
BLAKE2b-256 | c1f8b4d9696b745947dae5385d27cee46d7e92f010dd089aa923d7c12c314b5e |