Package: yaml-requests
yaml_requestsA simple python app for sending a set of consecutive HTTP requests defined in YAML requests plan.InstallingEnsure that you are using Python >= 3.7 withpython --version. This app/package is available inPyPI. To install, run:pipinstallyaml_requestsUsageThe app is used to execute HTTP requests defined in YAML files. The YAML file must contain main-level keyrequests, that contains an array of requests, where each item of the list is a request object. The request object contains at least a method key (get,post,options, ...) which value is passed torequests.requestfunction, or torequests.Session.requestif plan level optionsessionis truthy.Minimal YAML request plan should thus include requests array, with single item in it:requests:-get:url:https://google.comIn addition to this basic behavior, more advanced features are provided as well:All value fields in requests array items support jinja2 templating.Variables can be defined in YAML request plan and overridden from commandline arguments.Response of the most recent request is stored inresponsevariable asrequests.Responseobject.Responses can be stored as variables withregisterkeyword.Response can be verified with assertions.Plan execution can be repeated by settingrepeate_whileoption.Advanced ExampleHere is an advanced example:name:Simulate execution of a build from queuevariables:base_url:http://localhost:5000node:defaultrequests:-name:Get queued itemsget:url:"{{base_url}}/queue"assert:-name:Queue is not emptyexpression:response.json() | length-name:Status code is 200expression:response.status_code == 200-name:Request took less than 5 secondsexpression:response.elapsed.total_seconds() < 5register:queue_response_1-name:"Createbuildforfirstiteminthequeue({{response.json().0.id}})"post:url:"{{base_url}}/queue/{{response.json().0.id}}/init"json:node:"{{node}}"register:build_create-name:Get queued itemsget:url:"{{base_url}}/queue"assert:-name:Queue is shorter than initiallyexpression:response.json() | length < queue_response_1.json() | length-name:"Completethecreatedbuild({{build_create.json().build_id}})"post:url:"{{base_url}}/builds/{{build_create.json().build_id}}/complete"-name:Output build detailsget:url:"{{base_url}}/builds/{{build_create.json().build_id}}"output:yamlRunning the ExampleThis example can be run against the dummy API provided bytst/server/api.pyStart by making sure thatflaskis installed:python-mpipinstallflaskThen run the test server:python-mflask--apptst/server/api.pyrunWith the test server running execute the plan using the command:yaml_requeststst/plans/build_queue.ymlMore examplesThere are more examples available intst/plansdirectory and can be executed as follows:yaml_requeststst/plans/minimal_plan.yml
yaml_requeststst/plans/build_queue.ymlHelpSeeyaml_requests --helpfor full CLI usage.TestingCheck and automatically fix formatting with:pycodestyleyaml_requests
autopep8-aaar--in-placeyaml_requestsRun static analysis with:pylint-E--enable=invalid-name,unused-import,useless-object-inheritanceyaml_requestsRun unit tests with command:python3-munittestdiscover-stst/Get test coverage with commands:coveragerun--branch--sourceyaml_requests/-munittestdiscover-stst/
coveragereport-m