Provides testing for JSON APIs with Behave
Project description
Provides testing for JSON APIs with Behave [1]
Installation
pip install behave-web-api
Import steps in your features/steps/__init__.py
from behave_web_api.steps import *
So you can use the steps in your feature files
Feature: Doing http requests
Scenario: Send text body and headers
Given I set header "X-My-Header" with value "Something"
When I send a POST request to "/requests/echo" with body:
"""
Something
"""
Then the response code should be 200
And the response should contain json:
"""
{
"headers": {
"X-My-Header": "Something"
},
"body": "%[A-Za-z]+%"
}
"""
Scenario: Send file using variables and environment variables
Given I set the variable "DATA_DIR" with value "$PWD/features/data"
And I attach the file "$DATA_DIR/favicon.ico" as "upload"
When I send a POST request to "/requests/echo"
Then the response code should be 200
And print response
And run using BASE_URL environment variable:
BASE_URL=localhost:5000 behave features/requests.feature
Available Steps
Given I set variable “{}” with value “{}”
Given I set header “{}” with value “{}”
Given I attach the file “{}” as “{}”
When I send a {} request to “{}” with body:
When I send a {} request to “{}” with values:
When I send a {} request to “{}”
Then the response code should be {}
Then the response should contain json:
Then the response should contain text:
Then print response
Acknowledgments
The REST steps are based on Behat WebApiExtension [2]
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
Built Distribution
Hashes for behave_web_api-1.0.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b95e56bf6c17d872d7a988f6517110c384a954917e0f0e01a5cf79a058c2db16 |
|
MD5 | 1bd92babfdd8c6e865a198893e7bc53e |
|
BLAKE2b-256 | d7c5582e377ddef83424575b6d3561caa4eb8b6f060a99be2f68763940d8cf05 |