assert get_env('x') == ''RestReqFactory
ENV map to handle env variables
get_env
get_env (x:str)
| Type | Details | |
|---|---|---|
| x | str | key to filter | 
set_env
set_env (key:str, val:str)
| Type | Details | |
|---|---|---|
| key | str | key to map variable | 
| val | str | value of the key | 
set_env('x', 3)
assert get_env('x') == 3RestReq
Base class to hold attributes of the rest request.
RestReq
RestReq (method:str, url:str, headers:Optional[dict]=None, params:Optional[dict]=None, body:Optional[dict]=None, kwargs:Optional[dict]=None)
Rest request building method
req = RestReq(
    method="POST",
    url='https://httpbin.org/post',
    headers={
    "accept": "application/json",
    },
)To extract curl repr
req.curl"curl -X POST 'https://httpbin.org/post' -H 'accept: application/json'"
To invoke the rest call
resp = req()
type(resp)requests.models.Response
RestReqFactory
Class to bind the lambda function to create RestReq object`
RestReqFactory
RestReqFactory (method:str, url_provider:<function <lambda>>, headers_provider=<function <lambda>>, params_provider=<function <lambda>>, body_provider=<function <lambda>>)
Class to bind the lambda function to create RestReq object
| Type | Default | Details | |
|---|---|---|---|
| method | str | represents the request method | |
| url_provider | function returning url | ||
| headers_provider | function | function returning headers | |
| params_provider | function | function returning params | |
| body_provider | function | function returning params | 
Build basic RestReqFactory object
url = lambda: f"{get_env('url')}/post"
head = lambda : {
    "accept": f"{get_env('accept')}",
}
# Create the RestReqFactory instance
req = RestReqFactory(
    method="POST",
    url_provider=url,
    headers_provider=head,
)assert req().curl == """curl -X POST '/post' -H 'accept: '"""leveraging Dynammic nature of ENV
set_env('url', 'https://httpbin.org')
set_env('accept', 'application/json')assert req().curl == """curl -X POST 'https://httpbin.org/post' -H 'accept: application/json'"""resp = req()()
assert resp.status_code  == 200req(){
    "method": "POST",
    "url": "https://httpbin.org/post",
    "headers": {
        "accept": "application/json"
    },
    "params": "None",
    "body": "None",
    "kwargs": "None"
}