BDD HTTP steps implementation for Behave
A Python package for HTTP-service testing. Contains reusable steps for Behave BDD (behaviour-driven development) tool. It’s mostly useful for testing REST APIs and interacting with JSON data over HTTP.
Usage
yourapp/features/environment.py:
from behave_http.environment import before_scenario
yourapp/features/steps/some_http_stuff.py:
from behave_http.steps import *
(You can mix them with your own steps in the same file.)
yourapp/features/some_api.feature:
Feature: Some API
As an API client
I want to be able to manage activities and sessions
Background: Set server name, headers and reset test user's database
Given I am using server "$SERVER"
And I set base URL to "$URL"
And I set "Accept" header to "application/json"
And I set "Content-Type" header to "application/json"
And I set BasicAuth username to "t@example.com" and password to "t"
Scenario: Ensure account exists
When I make a GET request to "account"
Then the response status should be 200
If your test target is http://127.0.0.1:8081/api you can test it with:
SERVER=http://127.0.0.1:8081 URL=api behave
General rules on using quoted "values" in feature files:
JSONs and numbers (response code, array length) must appear as is.
Other substitutes must be quoted (variable names, headers and their values).
While there is no extensive documentation the features (self tests) directory contains (a hopefully complete) set of usage examples.
Testing for nested JSON content with non-ASCII characters in paths is not supported by the underlying ``jpath`` library.
Development
To install essential packages for the test suite:
pip install -r requirements_dev.txt
A complete list of development tools used in the Makefile can be installed with:
pip install coveralls docutils flake8 tox wheel
Running tests
Launch a special HTTP server responding to test requests:
python testserver.py
Then run feature tests in a separate shell:
make test-all # runs on every supported python version with tox make test # runs in current python environment only
Environment variables
Set TEST_SERVER to full URL (including schema) if default port (55080) on localhost is already used by another process. For example:
export TEST_SERVER=http://127.0.0.1:55081 python testserver.py >testserver.log 2>&1 & make test-coverage
Acknowledgments
The REST steps code is initially derived from rest api blueprint [1], so this project inherits the same BSD 2-Clause License (see LICENSE file).
Metadata
Release files for behave-http 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| behave_http-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for behave_http-0.1.1-py2.py3-none-any.whl |
Release files / behave_http-0.1.1-py2.py3-none-any.whl
| Download URL | behave_http-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
406dae9989d4bee08e01f59366b337a6a479e837bcd40b1ec6553e25b4338fb7
|
|
BLAKE2b-256 checksum How to use checksums |
6e1f54c10c1c05a3290e7487835f698e2f95466c5c8934490b1bfe7bed09035c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for behave-http 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.