Skip to main content

A library to use postman collections V2.1 in python.

Project description

postman2py

postman2py is a library for Postman that run Postman's collections. Originaly was forked from https://github.com/k3rn3l-p4n1c/postpython and updated to Postman collection v2.1 format. If you are using postman, but collection runner is not flexible enough for you and postman codegen is too boring, postman2py is here for your continuous integration.

Why use postman2py instead of postman codegen?

  • Postman codegen should be applied one by one for each request and it's boring when your API changes, but with Postpy2, you don't need to generate code. Just export collection with Postman and use it with Postpy2.
  • In code generation, you don't have environment feature anymore and variables are hard coded.

Why user postman2py instead of Postman collection runner?

  • With postman2py, you write your own script. But collection runner just turns all your requests one by one. So with postman2py, you can design more complex test suites.

How to install?

postman2py is available on PyPI and you can install it using pip:

$ pip install postpy3

How to use?

Import postman2py

from postpy3.core import PostPython

Make an instance from postman2py and give the address of postman collection file.

runner = postman2py('/path/to/collection/Postman echo.postman_collection')

Now you can call your request. Folders' name change to upper camel case and requests' name change to lowercase form. In this example the name of folder is "Request Methods" and it's change to RequestMethods and the name of request was "GET Request" and it's change to get_request. So you should call a function like runner.YourFolderName.you_request_name()

response = runner.RequestMethods.get_request()
print(response.json())
print(response.status_code)

Load enviroment variables

In postman2py you can load enviromental variables from postman enviroment files

pp.environments.load('environments/test.postman_environment.json')

Variable assignment

In postman2py you can assign values to environment variables in runtime.

runner.environments.update({'BASE_URL': 'http://127.0.0.1:5000'})
runner.environments.update({'PASSWORD': 'test', 'EMAIL': 'you@email.com'})

AttributeError

Since RequestMethods and get_request does not really exists your intelligent IDE cannot help you. So postman2py tries to correct your mistakes. If you spell a function or folder wrong it will suggest you the closest name.

>>> response = runner.RequestMethods.get_requasts()

Traceback (most recent call last):
File "test.py", line 11, in <module>
response = runner.RequestMethods.get_requasts()
File "/usr/local/lib/python3.5/site-packages/postman2py/core.py", line 73, in **getattr**
'Did you mean %s' % (item, self.name, similar))
AttributeError: get_requasts request does not exist in RequestMethods folder.
Did you mean get_request

You can also use help() method to print all available requests.

>>> runner.help()
>>> Posible requests:
>>> runner.AuthOthers.hawk_auth()
>>> runner.AuthOthers.basic_auth()
>>> runner.AuthOthers.oauth1_0_verify_signature()
>>> runner.RequestMethods.get_request()
>>> runner.RequestMethods.put_request()
>>> runner.RequestMethods.delete_request()
>>> runner.RequestMethods.post_request()
>>> runner.RequestMethods.patch_request()
>>> ...

>>> runner.RequestMethods.help()
>>> runner.RequestMethods.delete_request()
>>> runner.RequestMethods.patch_request()
>>> runner.RequestMethods.get_request()
>>> runner.RequestMethods.put_request()
>>> runner.RequestMethods.post_request()

Project details


Download files

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

Source Distribution

postman2py-0.0.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

postman2py-0.0.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file postman2py-0.0.1.tar.gz.

File metadata

  • Download URL: postman2py-0.0.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for postman2py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d0368f0e9f50c3c93f71f5cd17d9c133b4bedc975c02fd180a844a347531e8f5
MD5 8d42002c76376c873246b5d037c4bf3b
BLAKE2b-256 d51a050e98e97a4a2d0f2c7d8df3ebf38ce514ab44ad1d038c0c401672e18c04

See more details on using hashes here.

File details

Details for the file postman2py-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: postman2py-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for postman2py-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40ea7334352ea63d99f16ae8345e60299af10742bd28c1a20eb2d56c54689156
MD5 e93729ea5479698ad5b14f1a2aadf918
BLAKE2b-256 3c20074d3095fa0d94a3933c065c6445f8be5ae0f5f52f200b7535f1fb4955e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page