Package: api-automation-kit
Main FeaturesHere are just a few of the things that api-automation-kit including:Codeless Automation Framework For Performance and Rest API Tests - based on Streamlit and Locust python packagesAPI capbabilities - based on Requests python packageUpload Artifact to Pypi and AzureAPI Test Plan Capabilities For Azure TFSInteractive Test Report - based on Allure frameworkEnvironment and InstallationsInstall python 3.9Install Latest Pycharm IDE and open itOpen project directory and Create Virtual EnvironmentInstall Scoop (for windows)
See thefull installation instructions for ScoopInstall Allure
See thefull installation instructions for AllureInstall api-automation-kit Package from pypi:# PyPIpipinstallapi-automation-kitCode Examples:UI-App:# the code for open the ui appimportos.path
importapipath=os.path.dirname(__file__)api.ui_app.run_app(main_path=path)# run from command line$streamlitrunui.pyAfter a few seconds, the app will start on the default browser.- Try to create your first API test like the example below:Click on Save Result Check-Box for saving the Python syntax result:The Python script moved to your project folder:For run the test return to the web app and click on the Run Script.After a few seconds, the test results will appear in a new tab (allure installation is required):- Try to create your first Performance test like the example below:Click on Save Result Check-Box for saving the Python syntax result:The Python script moved to your project folder:Before you run your test, please add a new master.conf file to your main project folder:# master.conf basic argumentsweb-host=localhost
web-port=8089master.conf folder location:For run the test return to the web app and click on the Run Script.After a few seconds a new local server will be open. click on the link that appear on the screen and start your performance test with Locust package (Read more aboutLocust):Rest API:# the code for open the ui appimportallure
importapi


@allure.feature("Set Feature For get_en_stable")@allure.description("Set Description For get_en_stable")deftest_get_en_stable_():component_get_en_stable_()@allure.step("Set Step Description For get_en_stable")defcomponent_get_en_stable_():api_instance=api.rest_api.ApiCapabilities()response=api_instance.get_request(url='http://docs.locust.io:80/en/stable/?',headers={"Content-Type":"application/json"})analyze_response(response,200)@allure.step("Expected Status Code")defanalyze_response(res,expected_status_code):ifres.status_code!=expected_status_code:assertFalseelse:print(f"status code is {res.status_code}")# run the tests from command line$py.testrest_api.py--alluredir=tmp/allure_results# generate report from command line$allureservetmp\allure_resultsUpload Artifact:Optional arguments (pypi configuration):ParameterDescription--pypi-userthe user for pypi--pypi-passwordthe password for pypiUpdate the pip.ini file in your python virtual environemnt (azure configuration):[global]index-url=https://pypi.python.org/simple
extra-index-url=https://{organization-url}/{project}/_packaging/{feed-name}/pypi/simple/# upload python package to azure or pypiimportos
fromapiimportartifactPYPI=TrueAZURE=Falsepypi_user=os.environ.get('pypi-user')pypi_password=os.environ.get('pypi-password')azure_feeds='<azure-feed-1>'dist_dir=os.path.dirname(__file__)+"/dist"artifact.run_process(dist_dir=dist_dir,azure_feeds=azure_feeds,azure_artifact=AZURE,pypi_artifact=PYPI,user=pypi_user,password=pypi_password)Azure API:Optional arguments:ParameterDescription--organization-urlazure organization url--projectazure project name--ownerazure user name--access-tokenthe password for azure authorization header to access REST APIsgenerate access tokenhow to get azure test plan object:importapi# initiate azure test plan objectazure=api.azure_utils.AzureTestPlan()# how to get test plan all objectsazure_tp=azure.get_test_plan()# how to get test caseazure_tc=azure.get_test_case(plan_id={azure_plan_id},suite_id={azure_suite_id},test_case_id={azure_test_case_id})how to run test based on allure framework (https://docs.qameta.io/allure):step 1 - run test & generate report:importallure


@allure.feature("Set Feature Name For test_component function")@allure.description("Set Description For test_component function")deftest_component():step_1()@allure.step("Set Step 1 Description")defstep_1():pass


@allure.step("Set Step 2 Description")defstep_2():pass


@allure.step("Set Step 3 Description ")defstep_3():pass# run the tests from command line$py.test{script_name}.py--alluredir=tmp/allure_resultsThe test result will be in your project folder:step 2 - read test report & create new test on azure board:importapiazure=api.azure_utils.AzureTestPlan()json_path='{allure_json_result_path}'azure.create_new_tc_on_azure(json_path=json_path)step 3 - the test case was created on azure:Dependenciesallure-pytest~=2.9.43allure-python-commons~=2.9.43setuptools~=57.4.0genson~=1.2.2artifacts-keyring~=0.3.1twine~=3.4.2wheel~=0.37.0pandas~=1.3.3streamlit~=1.0.0locust~=2.2.3requests~=2.26.0azure-devops==6.0.0b4xmltojson~=0.2.0msrest~=0.6.21LicenseMIT