Skip to main content

A command-line tool for HTTP tests over RESTful APIs

Project description

https://travis-ci.org/slaily/pyhttptest.svg?branch=master

Pissed about writing test scripts against your RESTFul APIs anytime?

Describe an HTTP Requests test cases in a simplest and widely used format JSON within a file.

Run one command and gain a summary report.

📣

📣 Coverage measuring on Test Cases coming soon

📣

pyhttptest in the command line

Installation

Recommended installation method is to use pip:

$ pip install pyhttptest

Python version 3+ is required.

Usage

$ pyhttptest execute FILE

See also pyhttptest --help.

Examples

Single test case

Create a .json file and define a test case like an example:

FILE: HTTP_GET.json

{
  "name": "TEST: List all users",
  "verb": "GET",
  "endpoint": "users",
  "host": "https://github.com",
  "headers": {
    "Accept-Language": "en-US"
  },
  "query_string": {
    "limit": 5
  }
}

Execute a test case:

$ pyhttptest execute FILE_PATH/HTTP_GET.json

Result:

pyhttptest in the command line

Мultiple test cases

Create a .json file and define a test cases like an example:

FILE: requests.json

[
  {
    "name":"TEST: List all users",
    "verb":"GET",
    "endpoint":"api/v1/users",
    "host":"http://localhost:8085/",
    "headers":{
       "Accept-Language":"en-US"
    },
    "query_string":{
       "limit":1
    }
  },
  {
    "name":"TEST: Add a new user",
    "verb":"POST",
    "endpoint":"api/v1/users",
    "host":"http://localhost:8085/",
    "payload":{
       "username":"pyhttptest",
       "email":"admin@pyhttptest.com"
    }
  },
  {
    "name":"TEST: Modify an existing user",
    "verb":"PUT",
    "endpoint":"api/v1/users/XeEsscGqweEttXsgY",
    "host":"http://localhost:8085/",
    "payload":{
       "username":"pyhttptest"
    }
  },
  {
    "name":"TEST: Delete an existing user",
    "verb":"DELETE",
    "endpoint":"api/v1/users/XeEsscGqweEttXsgY",
    "host":"http://localhost:8085/"
  }
]

Execute a test case:

$ pyhttptest execute FILE_PATH/requests.json

Result:

pyhttptest in the command line

Dependencies

Under the hood, pyhttptest uses these amazing libraries:

  • ijson — Iterative JSON parser with a standard Python iterator interface
  • jsonschema — An implementation of JSON Schema validation for Python
  • Requests — Python HTTP library for humans
  • tabulate — Pretty-print tabular data
  • click — Composable command line interface toolkit

Contributing

See CONTRIBUTING.

Changelog

See CHANGELOG.

Licence

BSD-3-Clause: LICENSE.

Authors

Iliyan Slavov

Project details


Download files

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

Files for pyhttptest, version 0.7
Filename, size File type Python version Upload date Hashes
Filename, size pyhttptest-0.7-py3-none-any.whl (15.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyhttptest-0.7.tar.gz (11.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page