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"
And I set header "Content-Type" with value "application/json"
When I send a POST request to "/requests/echo" with body:
"""
{
"a": 1,
"b": "",
"c": "0101",
"d": "[01]+"
}
"""
Then the response code should be 200
And the response should contain json:
"""
{
"headers": {
"X-My-Header": "Something"
},
"body": {
"a": "<is_number>",
"b": "%.*%",
"c": "%[01]+%",
"d": "[01]+"
}
}
"""
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
File details
Details for the file behave-web-api-2.0.1.tar.gz
.
File metadata
- Download URL: behave-web-api-2.0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/2.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c61a60280e275e035a5a0e0e5c2838a176e8f675819361a453754cc6cdd5e512 |
|
MD5 | ef0d4f9de3e2c3d6028a9ebc5cf30335 |
|
BLAKE2b-256 | 13cdfd2a080897dc58f9c72a2ceb5392e0373f4dc0d295d4e5c2012c42e6d60e |
File details
Details for the file behave_web_api-2.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: behave_web_api-2.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/2.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee2496a51dbd5b30b018e4758a8d0d7c5326c21c2c9fe8ae5fbafc61ec161eaa |
|
MD5 | db71321f4626f0861a9103a87de47327 |
|
BLAKE2b-256 | bb20f28cbad3bf51539bbe7fea107814c5b4bbb7762972fb20f135ba77053412 |