Skip to main content

Build Status Version

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]

Metadata

Release files for behave-web-api 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for behave-web-api 1.0.7
File Size Uploaded
behave-web-api-1.0.7.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for behave-web-api 1.0.7
File Interpreter ABI Platform
behave_web_api-1.0.7-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.1 kB

Release files / behave-web-api-1.0.7.tar.gz

Download URL behave-web-api-1.0.7.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7111f1949710cd6d910928746137f7685f14eb84127f98475f14f42821bcd662
BLAKE2b-256 checksum
How to use checksums
a14d97e7d1b71062a324095ebb0cb1c162955d195fc3e73e0a24ef6f608b5e01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.7

Release files / behave_web_api-1.0.7-py2.py3-none-any.whl

Download URL behave_web_api-1.0.7-py2.py3-none-any.whl
Size 5.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b95e56bf6c17d872d7a988f6517110c384a954917e0f0e01a5cf79a058c2db16
BLAKE2b-256 checksum
How to use checksums
d7c5582e377ddef83424575b6d3561caa4eb8b6f060a99be2f68763940d8cf05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.7

Release history Release notifications | RSS feed

2.4.0

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.8

2 release files

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

1 release file

1.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page