matkapi / postpy2

Postman collection runner library for python
Other
35 stars 15 forks source link

Enhancement: Option to allow to access all the methods dynamically #17

Open gitphoex opened 2 years ago

gitphoex commented 2 years ago

Hi,

I was looking for a tool to execute collection in parallel. Though this can be achieved by writing script using newman (from postman), it needs nmp setup in my machine. Since, I don't use NPM I was looking a simpler approach and found this project. Now, the only problem here is I have to write method names in my code that is too much of coding.

Below enhancements will be beneficial for users:

  1. Option to access the methods in list format and then execute the same. e.g.:

    # ===============================================================
    # Get filtered the collection Items and requests 
    # ===============================================================
    
    runner = PostPython('/path/to/collection/postman_collection.json')
    collection_items = runner.get_collecdtion_items()
    for collection_item in collection_items:
        requests = collection_item.get_requests()
        for request in requests:
            response = request()
    
    # ===============================================================
    # Get filtered the collection Items and requests                         
    # ===============================================================
    runner = PostPython('/path/to/collection/postman_collection.json')
    
    # collection items containing certain string
    collection_items = runner.get_collecdtion_items("*foo*")
    for collection_item in collection_items:
        # requests starting with certain string
        requests = collection_item.get_requests("bar*")
        for request in requests:
            response = request()
  2. Option to execute the methods by its name e.g.:

    
    runner = PostPython('/path/to/collection/postman_collection.json')
    response = runner.execute_reqeust("CollectionItem.get_request")

3. Option to execute the whole collection (with filter)
    e.g.: 
runner = PostPython('/path/to/collection/postman_collection.json')
responses = runner.execute_collection(filter="*foo_bar*" , parallel=true)
for response in responses:
   print(response.json())
   print(response.status_code)

3. Option to execute the whole collection (with filter)
    e.g.: 
runner = PostPython('/path/to/collection/postman_collection.json')
responses = runner.execute_collection(filter="*foo_bar*" , parallel=true)
for response in responses:
   print(response.json())
   print(response.status_code)


This will be helpful in case of collection with lots of requests.