Skip to main content

No project description provided

Project description

项目介绍

此扩展包通过读取yaml文件配置接口请求参数 通过GET、POST方法获取接口返回值并断言

安装和使用

安装命令如下:
pip install ytApiTest
支持功能如下:
  • 支持 GET 请求

  • 支持 POST 请求

  • 支持 yaml文件内请求参数或断言数据使用JOSNPATH 语法获取接口返回值

  • 支持 断言接口返回值,字段某部分或某个键值对是否存在返回值中

  • 支持 断言接口返回值所有字段是否与断言值相等

  • 支持 断言失败发送对应错误接口信息到钉钉群

使用:
  • 使用扩展包项目根目录下必须新建.yaml文件管理测试用例数据

  • .yaml文件必须遵循以下格式并包含以下关键字

配置钉钉机器人URL
DING_TALK_URL: https://钉钉机器人URL

项目host
OBJECT_HOST: https://object/host

账号host
ACCOUNT_URL: https://account_host/user/login2

登录账号请求用户名密码
ACCOUNT_DATA: 账号登录请求参数

interface_name(你接口名称,可自己命名):
                            url(接口路径,此关键字必须包含): 值可为空
                            assert_key(断言key,可自己命名):
                                                des(此关键字必须包含): 用例说明值可为空,用于断言错误时展示
                                                req_data(此关键字必须包含): 接口请求参数,值可为空
                                                ast_data(此关键字必须包含): 接口断言值,值可为空
  • .yaml文件内使用JSONPATH语法示例

interface_name:
                url:
                assert_key:
                            des:
                            req_data:
                                        key: $.interface_name.data.XXX
                            ast_data:
                                        key: $.interface_name.data.XXX

方法说明及使用示例

#POST 请求
import ytApiTest
#读取.yaml文件内对应的接口值并发送post请求到后台,返回response对象
response = ytApiTest.post(interface_name,assert_key)
#参数说明:interface_name(.yaml你接口名称),assert_key(.yaml文件内与接口对应的assert_key值)
#GET 请求
import ytApiTest
#读取.yaml文件内对应的接口值并发送get请求到后台,返回response对象
response = ytApiTest.get(interface_name,assert_key)
#参数说明:interface_name(.yaml你接口名称),assert_key(.yaml文件内与接口对应的assert_key值)
#获取接口断言数据
import ytApiTest
#读取.yaml文件内对应的接口值并发送post请求到后台,返回response对象
response = ytApiTest.get_interface_case_assert_data(interface_name,assert_key)
#参数说明:interface_name(.yaml你接口名称),assert_key(.yaml文件内与接口对应的assert_key值)
#获取接口请求数据
import ytApiTest
#读取.yaml文件内对应的接口值并发送post请求到后台,返回response对象
response = ytApiTest.get_interface_request_data(interface_name,assert_key)
#参数说明:interface_name(.yaml你接口名称),assert_key(.yaml文件内与接口对应的assert_key值)
#获取接口完整URL
import ytApiTest
#读取.yaml文件内对应的接口值并发送post请求到后台,返回response对象
response = ytApiTest.get_interface_url(interface_name,assert_key)
#参数说明:interface_name(.yaml你接口名称),assert_key(.yaml文件内与接口对应的assert_key值)
#执行相等断言方法
import ytApiTest
#读取.yaml文件内对应的接口值并发送post请求到后台,返回response对象
ytApiTest.assert_body_ep_value(response,assert_value)
#参数说明:response(接口返回response对象),assert_value(.yaml文件内断言值)
#执行包含断言方法
import ytApiTest
#读取.yaml文件内对应的接口值并发送post请求到后台,返回response对象
ytApiTest.assert_body_include_value(response,assert_value)
#参数说明:response(接口返回response对象),assert_value(.yaml文件内断言值)
#断言返回值中URL状态是否为200方法
import ytApiTest
#读取.yaml文件内对应的接口值并发送post请求到后台,返回response对象
ytApiTest.assert_response_url_status(response
#参数说明:response(接口返回response对象)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ytApiTest-1.0.6.tar.gz (10.4 kB view details)

Uploaded Source

File details

Details for the file ytApiTest-1.0.6.tar.gz.

File metadata

  • Download URL: ytApiTest-1.0.6.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for ytApiTest-1.0.6.tar.gz
Algorithm Hash digest
SHA256 db04c0ff8965de1656f15e8a007d2021ac9e726f8ea97f81711084b2b8a23c1b
MD5 f3718a91025c1ca41490f521f32274e0
BLAKE2b-256 6e0b01a6c708d34fce694746be577450ea9484bbc0e73deec6b269484ded39d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page