Skip to main content

Provides testing for JSON APIs with Behave

Project description

Build Status

Provides testing for JSON APIs with Behave

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 "$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

  • I set variable “{}” with value “{}”
  • I set header “{}” with value “{}”
  • I attach the file “{}” as “{}”
  • I send a {} request to “{}” with body
  • I send a {} request to “{}” with values
  • I send a {} request to “{}”
  • the response code should be {}
  • the response should contain json
  • the response should contain text
  • print response

Acknowledgments

The REST steps are based on Behat WebApiExtension [1]

[1]https://github.com/Behat/WebApiExtension

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for behave-web-api, version 1.0.6
Filename, size File type Python version Upload date Hashes
Filename, size behave_web_api-1.0.6-py2.py3-none-any.whl (6.3 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size behave-web-api-1.0.6.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page