Skip to main content

My short description for my project.

Project description

About

A basic library could decrease the workload.Most of the problem solved in a real testing job.

Function info

interface test

parameter template url = "https://test/api/log?requestID=testid&clientToken=testtoken" body ={"date": "2018-11-04 10:10:10", "actions": [{"actionTime": 1542248466944,"note"]}}

interface basic verification


verification of the value of parameter is null

verification of the parameter in a GET method restful interface link, such as requestID:

url = "https://test/api/log?requestID=&clientToken=testtoken"

verification of request body in a POST restful interface, type of the body, such as form or raw will self adapted. e.g

body ={"date": "", "actions": [{"actionTime": 1542248466944,"note"]}}

body ={"date": "2018-11-04 10:10:10", "actions": [{"actionTime": "","note"]}}

the value of parameter is ""

verification of null parameter

verification of the parameter in a GET method restful interface link, such as requestID:

url = "https://test/api/log?clientToken=testtoken"

verification of request body in a POST restful interface, type of the body, such as form or raw will self adapted. e.g

body ={ "actions": [{"actionTime": 1542248466944,"note"]}}

body ={"date": "2018-11-04 10:10:10", "actions": [{"note"]}}

verification of length of parameter

range of the length is 1 to 100000。


performance test of interface coming soon UI automatic test

how to install

pip install BlueTest

or

https://pypi.org/project/BlueTest/

Usage and examples

example

└─Project
        test1.py

test1.py:

import BlueTest
BlueTest.test()

└─Project
  test1.py
├─log
      all.log #log
      error.log #error log
├─result #reuslt
      data.txt
└─srcdata
      test.csv  #postman serialize
      test.json.postman_collection #postman example
    └─api #generated .py file according postman
            log.py

Usage

import BlueTest
#This will produce the csv file for test case
BlueTest.initPostMan("test") 

#默认postamen文件路径
# default post man path is .//srcdata//name.json.collection
#default csv file path is.//srcdata//test.csv
BlueTest.testByCsvData("test") # this will produce the result

BlueTest.initPostMan("test") #this will produce the csv file
BlueTest.initPostMan("test",result_path=path) #specify the csv file path
BlueTest.testByCsvData("test") 
#this will produce the result 
BlueTest.testByCsvData("test",normal_test=True) #basic interface verification
BlueTest.testByCsvData("test",normal_test=Fasle) #not verify the result
BlueTest.testByCsvData("test",mkpy=True) 

import requests
url = "https://nbrecsys.4paradigm.com/action/api/log"
querystring = {'requestID': 'Abac6ban', 'clientToken': '1f9d3d10b0ab404e86c2e61a935d3888'}
payload = {"date":"2018-11-04 10:21:06","actions":[{"requestID":"2222","actionTime":1542248466944,"action":"show","sceneId":420,"userId":"xubyCjC6zO","itemId":"user_define","itemSetId":"39","uuid_tt_dd":"10_28867322960-222-222","specialType":"csdn_net_alliance_ads","ads":1}]}
headers ={'Origin': ' https://blog.csdn.net',
	 'User-Agent': ' Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36',
	 'Content-Type': ' text/plain',
	 'Accept': ' */*',
	 'Referer': ' https://blog.csdn.net/qq_37159430/article/details/79970518',
	 'Accept-Encoding': ' gzip, deflate, br',
	 'Accept-Language': ' zh-CN,zh;q=0.8'}
response = requests.request("POST", url, params=querystring,data=payload,)
print(response.text)

The other function refer to :gun:

简介

:waxing_gibbous_moon:几个本质懒到家,却被工作压迫的人。为了降低自己的工作量,拍脑袋决定编写一个让小白也可以使用的测试库。一切的出发点都是几个懒人在实际工作中遇到的问题和场景。做这一切的目的是为了少做事。:waning_gibbous_moon:

功能介绍

接口测试

参数模板 下文的介绍中会使用该模板进行说明 url = "https://test/api/log?requestID=testid&clientToken=testtoken" body ={"date": "2018-11-04 10:10:10", "actions": [{"actionTime": 1542248466944,"note"]}}


接口基础校验


参数值判空校验

链接中的参数校验,即一般情况下GET参数的校验,以requestID为例:

url = "https://test/api/log?requestID=&clientToken=testtoken"

请求主体参数的校验,即一般情况下POST参数的校验,form,raw等参数类型均自动处理。 以body中的date为例,请求参数如下:

body ={"date": "", "actions": [{"actionTime": 1542248466944,"note"]}}

以body中的actions[0][actionTime]为例,请求参数如下:

body ={"date": "2018-11-04 10:10:10", "actions": [{"actionTime": "","note"]}}

空值以空字符串为标准。


参数判空校验

链接中的参数校验,即一般情况下GET参数的校验,以requestID为例:

url = "https://test/api/log?clientToken=testtoken"

请求主体参数的校验,即一般情况下POST参数的校验,form,raw等参数类型均自动处理。 以body中的date为例,请求参数如下:

body ={ "actions": [{"actionTime": 1542248466944,"note"]}}

以body中的actions[0][actionTime]为例,请求参数如下:

body ={"date": "2018-11-04 10:10:10", "actions": [{"note"]}}

参数长度校验

参数长度校验范围为1-100000。


额外参数校验

增加非接口文档约定参数进行校验。但是只在数据层级发生变化时进行校验。插入数据的键值均等于"test" 范例数据只会进行以下几种情况的校验:

url = "https://test/api/log?requestID=testid&clientToken=testtoken&test=test" body ={"date": "2018-11-04 10:10:10", "actions": [{"actionTime": 1542248466944}}

url = "https://test/api/log?requestID=testid&clientToken=testtoken" body ={"date": "2018-11-04 10:10:10","test":"test", "actions": [{"actionTime": 1542248466944]}}

url = "https://test/api/log?requestID=testid&clientToken=testtoken" body ={"date": "2018-11-04 10:10:10", "actions": [{"actionTime": 1542248466944,"test":"test"]}}


接口性能测试 待添加 UI自动化 功能已实现,说明待添加

安装说明

安装命令pip install BlueTest

or

https://pypi.org/project/BlueTest/

使用说明及范例

范例

└─Project
        test1.py

test1.py:

import BlueTest
BlueTest.test()

└─Project
  test1.py
├─log
      all.log #日志
      error.log #错误日志
├─result #结果
      data.txt
└─srcdata
      test.csv  #postman文件的序列化
      test.json.postman_collection #范例的postman文件
    └─api #根据postman生成的相关接口py文件
            log.py

使用说明

import BlueTest
BlueTest.initPostMan("test") #执行完成会生成相应csv文件
#默认postamen文件路径.//srcdata//name.json.collection
#默认csv文件生成路径.//srcdata//test.csv
BlueTest.testByCsvData("test") #执行完成会生成相应结果
#结果包括 日志文件log 结果文件resul

BlueTest.initPostMan("test") #执行完成会生成相应csv文件
BlueTest.initPostMan("test",result_path=path) #指定csv文件生成路径
BlueTest.testByCsvData("test") #执行完成会生成相应结果
BlueTest.testByCsvData("test",normal_test=True) #进行接口基础验证
BlueTest.testByCsvData("test",normal_test=Fasle) #不进行接口基础验证
BlueTest.testByCsvData("test",limit_check=True,extras_check=True) #limit_check 进行参数长度校验 extras_check进行额外参数校验 输出结果如下

exceptionCheck: ['requestID']为空 urlparams:True response:(True, '{"statuses":[{"ActionLogStatusCode":0}]}') exceptionCheck: ['requestID']不传 urlparams:True response:(True, '{"statuses":[{"ActionLogStatusCode":0}]}') extrasCheck: ['requestID'] 额外参数校验 response:(False, '{"code":3401,"info":"上传日志的时间错误","data":null}')

BlueTest.testByCsvData("test",mkpy=True) #生成接口py文件范例如下
BlueTest.testByCsvData("test",mkpy=True) #生成接口py文件范例如下
BlueTest.testByCsvData("test",mkpy=True) #生成接口py文件范例如下

import requests
url = "https://nbrecsys.4paradigm.com/action/api/log"
querystring = {'requestID': 'Abac6ban', 'clientToken': '1f9d3d10b0ab404e86c2e61a935d3888'}
payload = {"date":"2018-11-04 10:21:06","actions":[{"requestID":"2222","actionTime":1542248466944,"action":"show","sceneId":420,"userId":"xubyCjC6zO","itemId":"user_define","itemSetId":"39","uuid_tt_dd":"10_28867322960-222-222","specialType":"csdn_net_alliance_ads","ads":1}]}
headers ={'Origin': ' https://blog.csdn.net',
	 'User-Agent': ' Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36',
	 'Content-Type': ' text/plain',
	 'Accept': ' */*',
	 'Referer': ' https://blog.csdn.net/qq_37159430/article/details/79970518',
	 'Accept-Encoding': ' gzip, deflate, br',
	 'Accept-Language': ' zh-CN,zh;q=0.8'}
response = requests.request("POST", url, params=querystring,data=payload,)
print(response.text)

其他功能详见源码 :gun:

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

BlueTest-0.2.3.tar.gz (15.9 kB view hashes)

Uploaded Source

Supported by

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