api-automation-kit-0.7.0
توضیحات
api-automation-kit-package (beta version)
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | api-automation-kit-0.7.0 |
| نام | api-automation-kit |
| نسخه کتابخانه | 0.7.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Automation Team |
| ایمیل نویسنده | automation.team@automation.co.il |
| آدرس صفحه اصلی | https://upload.pypi.org/legacy/ |
| آدرس اینترنتی | https://pypi.org/project/api-automation-kit/ |
| مجوز | MIT |
# Main Features
Here 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 packages
- API capbabilities - based on Requests python package
- Upload Artifact to Pypi and Azure
- API Test Plan Capabilities For Azure TFS
- Interactive Test Report - based on Allure framework
# Environment and Installations
- Install python 3.9
- Install Latest Pycharm IDE and open it
- Open project directory and Create Virtual Environment
- Install Scoop (for windows)
See the [full installation instructions for Scoop](https://scoop.sh)
- Install Allure
See the [full installation instructions for Allure](https://docs.qameta.io/allure)
- Install api-automation-kit Package from pypi:
```sh
# PyPI
pip install api-automation-kit
```
# Code Examples:
## UI-App:
```sh
# the code for open the ui app
import os.path
import api
path = os.path.dirname(__file__)
api.ui_app.run_app(main_path=path)
```
```sh
# run from command line
$ streamlit run ui.py
```
### After 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:
```sh
# master.conf basic arguments
web-host = localhost
web-port = 8089
```
##### master.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 about [Locust](https://locust.io/)):

## Rest API:
```sh
# the code for open the ui app
import allure
import api
@allure.feature("Set Feature For get_en_stable")
@allure.description("Set Description For get_en_stable")
def test_get_en_stable_():
component_get_en_stable_()
@allure.step("Set Step Description For get_en_stable")
def component_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")
def analyze_response(res, expected_status_code):
if res.status_code != expected_status_code:
assert False
else:
print(f"status code is {res.status_code}")
```
```sh
# run the tests from command line
$ py.test rest_api.py --alluredir=tmp/allure_results
```
```sh
# generate report from command line
$ allure serve tmp\allure_results
```
## Upload Artifact:
Optional arguments (pypi configuration):
| Parameter | Description |
| :-------------------------|:-------------|
| --pypi-user | the user for pypi
| --pypi-password | the password for pypi
Update the pip.ini file in your python virtual environemnt (azure configuration):
```sh
[global]
index-url=https://pypi.python.org/simple
extra-index-url=https://{organization-url}/{project}/_packaging/{feed-name}/pypi/simple/
```
```sh
# upload python package to azure or pypi
import os
from api import artifact
PYPI = True
AZURE = False
pypi_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:
| Parameter | Description |
| :-------------------------|:-------------|
| --organization-url | azure organization url
| --project | azure project name
| --owner | azure user name
| --access-token | the password for azure authorization header to access REST APIs [generate access token](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page)
### how to get azure test plan object:
```sh
import api
# initiate azure test plan object
azure = api.azure_utils.AzureTestPlan()
# how to get test plan all objects
azure_tp = azure.get_test_plan()
# how to get test case
azure_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:
```sh
import allure
@allure.feature("Set Feature Name For test_component function")
@allure.description("Set Description For test_component function")
def test_component():
step_1()
@allure.step("Set Step 1 Description")
def step_1():
pass
@allure.step("Set Step 2 Description")
def step_2():
pass
@allure.step("Set Step 3 Description ")
def step_3():
pass
```
```sh
# run the tests from command line
$ py.test {script_name}.py --alluredir=tmp/allure_results
```
##### The test result will be in your project folder:

#### step 2 - read test report & create new test on azure board:
```sh
import api
azure = 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:

# Dependencies
- allure-pytest~=2.9.43
- allure-python-commons~=2.9.43
- setuptools~=57.4.0
- genson~=1.2.2
- artifacts-keyring~=0.3.1
- twine~=3.4.2
- wheel~=0.37.0
- pandas~=1.3.3
- streamlit~=1.0.0
- locust~=2.2.3
- requests~=2.26.0
- azure-devops==6.0.0b4
- xmltojson~=0.2.0
- msrest~=0.6.21
# License
[MIT](LICENSE)
نیازمندی
| مقدار | نام |
|---|---|
| ~=2.9.43 | allure-pytest |
| ~=2.9.43 | allure-python-commons |
| - | setuptools |
| ~=1.2.2 | genson |
| ~=0.3.1 | artifacts-keyring |
| ~=3.4.2 | twine |
| ~=0.37.0 | wheel |
| ~=1.3.3 | pandas |
| ~=1.0.0 | streamlit |
| ~=2.2.3 | locust |
| ~=2.26.0 | requests |
| ==6.0.0b4 | azure-devops |
| ~=0.2.0 | xmltojson |
| ~=0.6.21 | msrest |
| ~=1.0.1 | utils |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8 | Python |
نحوه نصب
نصب پکیج whl api-automation-kit-0.7.0:
pip install api-automation-kit-0.7.0.whl
نصب پکیج tar.gz api-automation-kit-0.7.0:
pip install api-automation-kit-0.7.0.tar.gz