Maritest

Pipeline Passing Python version Code coverage Python status

Summary

Maritest is an API testing library that the purpose’s solely to simplifying assertion when doing testing in API layer, it’s an easy and convenient way to go iterative testing while keep up the fast-paced development and be able to maintain all testing modules / scenarios without breaking change

Features

  • Extending usage when doing HTTP request

  • Enrich and support logging for debug HTTP request

  • Built-in assertion to make easier when doing API testing

  • Support common HTTP authentication

Quick Usage

Using Python 3.7 below?

Maritest well-tested on Python version 3.7 and above, you may still be able to use it with Python 3.7 below but it’s expected there’s backward compatibility that will happen

The installation can be done with :

pip install maritest

After you’re done with installation, you can try to use this basic feature from Maritest for example :

# samples.py
from maritest.assertion import Assert

request = Assert(
   method="GET",                                       # required, support 5 common HTTP method
   url="https://jsonplaceholder.typicode.com/todos/1", # required
   headers={},                                         # not required, default set to empty dict
   proxy={"http": "api.services"},                     # not required, default set to None
   timeout=60,                                         # not required, default set to 120 seconds
)

# pick it up several method what kind of assertion that you wanted
# 1. Assert request is success or not
# 2. Assert request is failed or not
# 3. Assert content-type of HTTP
# 4. Assert response time when request HTTP
request.assert_is_ok(message="Request should be success")
request.assert_is_failed(message="Shouldn't be failed")
request.assert_is_content_type(message=None)
request.assert_response_time(duration=300)

Afterwards, wrap up that configuration and just run that file and it will automatically, the assertion testing process will execute without us needs to define the actual result or also set the expected result. If any of the assertion methods above it’s fail, it will raise an error message.

For more detailed information of using Maritest please refer to the Guides page and Assertion Usage.