Skip to main content

A toolchain for testing REST APIs in BDD manner.

Project description

# bddrest

Toolchain to define and verify REST API in BDD.

[![Build Status](http://img.shields.io/pypi/v/bddrest.svg)](https://pypi.python.org/pypi/bddrest)
[![Gitter](https://img.shields.io/gitter/room/Carrene/bddrest.svg)](https://gitter.im/Carrene/bddrest)

## Branches

### master

[![Build Status](https://travis-ci.org/Carrene/bddrest.svg?branch=master)](https://travis-ci.org/Carrene/bddrest)
[![Coverage Status](https://coveralls.io/repos/github/Carrene/bddrest/badge.svg?branch=master)](https://coveralls.io/github/Carrene/bddrest?branch=master)

### develop

[![Build Status](https://travis-ci.org/Carrene/bddrest.svg?branch=develop)](https://travis-ci.org/Carrene/bddrest)
[![Coverage Status](https://coveralls.io/repos/github/Carrene/bddrest/badge.svg?branch=develop)](https://coveralls.io/github/Carrene/bddrest?branch=develop)


## Quick start


```python

import sys
import json

from bddrest.authoring import given, when, then, and_, response, composer


def wsgi_application(environ, start_response):
path = environ['PATH_INFO']
if path.endswith('/None'):
start_response('404 Not Found', [('Content-Type', 'text/plain;charset=utf-8')])
return ''
start_response('200 OK', [('Content-Type', 'application/json;charset=utf-8')])
result = json.dumps(dict(
foo='bar'
))
yield result.encode()


with given(
wsgi_application,
title='Quickstart!',
url='/books/id: 1',
as_='visitor'):

then(response.status == '200 OK')
and_('foo' in response.json)
and_(response.json['foo'] == 'bar')

when(
'Trying invalid book id',
url_parameters={'id': None}
)

then(response.status_code == 404)

composer.dump(sys.stdout)

```

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

bddrest-0.5.0a3.tar.gz (8.7 kB view hashes)

Uploaded Source

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