当前位置:网站首页>Talking about interface test (2)
Talking about interface test (2)
2022-06-26 01:40:00 【NitefullSand】
1. Type of interface test
It mainly includes three kinds of tests :
- Web The interface test ,
- Application program interface (API, application programming interface) test ,
- Database test .
In fact, the meaning is UI Interface to database , All the processes that the data flow goes through .
1、LAMP(Linux Apache MySQL PHP)/LNMP(Linux Nginx MySQL PHP): Only Web The server , No application server :
- Web browser To Web The server : Web The interface test , test Requests and responses .
- Web The server To database server : Application interface test , test PHP.
2、Linux / Windows + Java / Asp.net(C#) + Apache/Nginx + Tomcat/IIS + MySQL/Oracle/SQL server
- Web browser To Web The server : Web The interface test , test Requests and responses .
- Web The server To application server : Contractual services ,WebService,JavaAPI,WebAPI,WCF,.net Remoting: test Java perhaps C# Process business logic (JavaEE/ ASP.NET MVC), Generally speaking, testing Service.
- application server To database server : Data processing services , test Java perhaps C# Processing data , Read the data into the database .
Here's what we need to focus on Web The interface test .
Web Method of interface test :
- Python perhaps Java,C# Programming , Trigger request , Read response , Analyze the response data and compare with the source data .
- With tools :Postman perhaps SoapUI( Not recommended )
Postman It was originally a Chrome Browser plug-ins , Now... Has been provided Windows、MacOS and Linux A standalone installation of . Next use Windows To install and use .
2. Postman Installation
download Postman Installation package , It is divided into 32 position and 64 position .https://www.getpostman.com
install Postman
Registered users (Sign Up) And login (Sign In)

Snap23.png
You can log in from multiple computers , The tests done will be synchronized automatically .

Snap24.png
After installing and logging in, you can start testing .

Snap25.png
3. Web Test point of interface
Web Interface by HTTP(S) request , It's a URL,URL Request the results , You get the data , There are two main data formats , A kind of JSON, A kind of XML. It mainly uses JSON demonstration .
- JSON, yes JavaScript Object Notation,JavaScript Object notation . It's used to show JavaScript The object of , perhaps JavaScript Data etc. . because JavaScript Widely used in Web Front page of , therefore JSON Mainly used in Web Interface . Main application scenarios :
- APP Communication between mobile terminal and server . Use the application layer HTTP agreement , adopt Web Interface reads data and processes ( Submit ) data .
- Web Communication between the front end and the server , Often the server is a third party , The main scenario is Payment and third party login .
- JD.COM web End call Wechat payment 、 TenPay pay 、 Alipay pay 、 UnionPay payment 、 E-currency payment ...
- JD.COM web End Support Wechat login 、QQ Sign in 、 Micro-blog login
- JD.COM web End Show Third party logistics information ( Shun Feng 、 sto 、 Tact ...)
- Public data , stay web End /APP End of the weather forecast It is provided by a third-party interface .
- XML,Extensible Markup Language, Extensible markup language ,HTML Namely XML A form of , adopt Pairing of labels , And the hierarchy of labels , To determine the content of the data .XML Mainly used in the backend Data transfer of application program interface , such as Java,C# etc. .XML Older formats .
Let's use an example , To separate JSON and XML Represents the following tabular data .
| employee_id | first_name | last_name | phone_number | hire_date | job_id | salary | |
|---|---|---|---|---|---|---|---|
| 100 | Steven | King | SKING | 515.123.4567 | 6/17/1987 | AD_PRES | 24000 |
| 101 | Neena | Kochhar | NKOCHHAR | 515.123.4568 | 9/21/1989 | AD_VP | 17000 |
First use JSON In the form of ,JSON yes “ Key value pair ”(Key Value) In the form of
{
"employees": [{
"employee_id": 100,
"first_name": "Steven",
"last_name": "King",
"email": "SKING",
"phone_number": "515.123.4567",
"hire_date": "6/17/1987",
"job_id": "AD_PRES",
"salary": 24000
},
{
"employee_id": 101,
"first_name": "Neena",
"last_name": "Kochhar",
"email": "NKOCHHAR",
"phone_number": "515.123.4568",
"hire_date": "9/21/1989",
"job_id": "AD_VP",
"salary": 17000
}]
}
Corresponding XML Format :
<?xml version="1.0" encoding="UTF-8" ?>
<employees>
<employee>
<employee_id>100</employee_id>
<first_name>Steven</first_name>
<last_name>King</last_name>
<email>SKING</email>
<phone_number>515.123.4567</phone_number>
<hire_date>6/17/1987</hire_date>
<job_id>AD_PRES</job_id>
<salary>24000</salary>
</employee>
<employee>
<employee_id>101</employee_id>
<first_name>Neena</first_name>
<last_name>Kochhar</last_name>
<email>NKOCHHAR</email>
<phone_number>515.123.4568</phone_number>
<hire_date>9/21/1989</hire_date>
<job_id>AD_VP</job_id>
<salary>17000</salary>
</employee>
</employees>
Web The definition of the interface determines the test content
- Method:GET POST PUT DELETE
- URL: The address of the interface
- Request parameters : Each parameter name , Type of parameter , The range of parameters , Is the parameter optional , Whether the parameter has a default value
- Equivalence class : Valid equivalent parameters , Invalid equivalent parameter
- The boundary value : Departure point , Upper point , Inside point
- Orthogonal test method :× factor × state
- sometimes , Association between parameters : province , City , county ( District ), Pay particular attention to illegal ( Invalid ) The associated
- Assertion : Check the contents of the response
- Text : Whether the body contains some characters
- Text :JSON perhaps XML Key value pair check for , Quantity check xx.length
- The status code of the response :200, 403
- Response time : 100ms, 200ms
*5. authentication : Do you have access to the interface
The actual object of the interface : data
- The format of the data
- Content of data
4. Postman Use
test Knowing weather API:https://www.seniverse.com/
Sign in Knowing weather ( To register first )
read Interface API file
- API The definition of : API Of URL The composition of And the request method
- API Parameters of
- Request parameters
- Response parameter
With Get real-time weather as an example :
API Methods and URL:GET, https://api.seniverse.com/v3/weather/now.json
API Parameters of :
Request parameters :
Parameter name Parameter type Parameter meaning Whether the choice key string Yours API secret key true location string The geographical location of the query true language string The language of the result representation false, Default simplified Chinese unit string The unit in which the result is expressed ( Fahrenheit , Centigrade ) false, Default Celsius Response parameter :
Parameter name Parameter type Parameter meaning location object : Include id, name, country, time_zone, time_zone_offset now object : Include text,code, temperature, feel_like... last_update date use Postman Start testing
new tab Input in The way , and URL
Click on Params Set parameters
Click on send Start sending requests
Check whether the request result has output , Whether the format corresponds to the above response parameters
{ "results": [ { "location": { "id": "WS10730EM8EV", "name": "Shenzhen", "country": "CN", "path": "Shenzhen,Shenzhen,Guangdong,China", "timezone": "Asia/Shanghai", "timezone_offset": "+08:00" }, "now": { "text": "Cloudy", "code": "4", "temperature": "25" }, "last_update": "2017-05-09T10:05:00+08:00" } ] }
edit Tests page , Add assertions .
var jsonData = JSON.parse(responseBody); tests[" Check city name "] = jsonData.results[0].location.name === "Shenzhen";
Use Postman Log in to the natural system , Test the login interface
Use natural 4.2 Or above
Modify the natural system The configuration file
C:\xampp5\htdocs\ranzhi\config\my.php, Add a line of configuration at the end , Here's the picture :
modify Of course The configuration file
$config->notEncryptedPwd = true;restart Apache
open Chrome, Enter the URL of ran , Open login page

Chrome Open login page
open Fiddler, And set up Chrome Carry out the bag
stay Chrome Log in , Submit username and password
stay Fiddler Capture the login just now in POST request

Fiddler Capture packets and log in POST
open Postman, newly build URL,POST Method .
Need to set up Postman, Click on File | Settings, Set it up

settings

Setting 2
stay Postman Enter just now Fiddler Requested POST Of URL

Fiddler Caught analysis
Enter the above URL

URL
stay Fiddler Between the second line of the copy request and the blank line in The message header (Head),Postman Input Head

Head 1

Head2.png
stay Fiddler Copy the body of the request in , stay Postman in body choice raw, And enter the

Input Body
stay Postman Of test Enter the following test content in :

Input assertion
var jsonData = JSON.parse(responseBody); tests[" Check locate"] = jsonData.locate === "\/sys\/index.html"; tests[" Check result"] = jsonData.result === "success"; tests["Status code is 200"] = responseCode.code === 200;stay Chrome Log out of , Note that this step is important , Only after you exit can you Postman Sign in

sign out Of course
stay Postman Click on the Send, To test

test result
see Postman Results of operation .

result.png
5. Web Interface authentication
Web Preparation of interface test
- HTTP Protocol request and response
request :GET/POST
Respond to :html/JSON/XML/CSS/JavaScript/png.. - The concept of testing
Assertion : Check the contents of the returned response .
Test design : Design the use case according to the requested parameters - Read the interface documentation
The way of request and URL
Request parameters and response parameters - Use authentication when requesting interfaces
basic authorization Basic certification , Enter your username and password
On the basis of the above four , Be careful Web The interface needs authentication , Especially the payment business , Here is an example , And is POST request + Basic Auth authentication , To illustrate this part .
Steps of the example :
open https://www.pingxx.com/ Ping++ Online payment website , Create an account , And login , An application will be created automatically .

Snap27.png
Enter the automatically created application , Enter the application control panel interface .
obtain
APP[id], Get... As shown in the figure , And use it later
Snap28.png
obtain
Test Secret Key, Get... As shown in the figure , And still wait to use
Snap29.png

Snap30.png
Follow the steps below , Look up API file , And start testing .

Snap31.png

Snap32.png

Snap33.png
choice Charge, Create a Payment order , Look up API Request parameters of the document , Response parameter , still Methods and URL

Snap34.png
stay Postman Create a new test in , Input POST and URL

Snap35.png
Set parameters , You need to use APP[id], Obtained for the previous step .

Snap36.png
stay Use... In request authentication ,Basic Auth, Input Obtained in the previous steps Test Secret Key, As user name .

Snap37.png

Snap38.png
Add test assertions .
use JavaScript Script , Inquire about JSON The value of the object , And check . Click on the ready-made menu on the right , Checks are automatically generated JSON Framework .
var jsonData = JSON.parse(responseBody);
tests[" Check object value "] = jsonData.object === "charge";
tests[" Check order_no value "] = jsonData.order_no === "99887766554433221100";
tests[" Check amount value "] = jsonData.amount === 9900;

Snap39.png
Click on Send Start testing .

Snap40.png
- Example 2: Create a red envelope Web The interface test
Interface description of wechat red packet payment interface test

Create a red envelope Web Interface description
stay Postman Input in POST Methods and URL

Paste_Image.png
stay Postman in Use Http Basic Auth authentication . Enter the previously obtained Secret_test_key. according to API Operations performed by the document

Paste_Image.png
stay Postman In the operation

Paste_Image.png

Paste_Image.png
Input Requested parameters , Be careful POST Requested request parameters , Input to Body in

enter text
stay Test Set assertion , Just now I said to set Object Validation of the .
Enter the following :

Assertion
var jsonData = JSON.parse(responseBody); tests[" Check Object attribute "] = jsonData.object === "red_envelope"; tests[" Check amount of money attribute "] = jsonData.amount === 6000;
Click on Send, Check .

result
Go to the management platform to view the order results .

Paste_Image.png
6. Postman Other functions of
Postman Support the export of use cases and the synchronization of accounts .

Snap41.png
Interface instance :
Weather forecast interface :
Interface URL: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
Network service description language : http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl
This interface has 5 A way :
- getSupportCity()
- getSupportDataSet()
- getSupportProvince()
- getWeatherbyCityName()
- getWeatherbyCityNamePro()By entering parameters , You can call these interfaces , And get the requested data .
Check this weather forecast Web Services Supported domestic and international city or regional information :
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity?byProvinceName= guangdong
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity?byProvinceName= Beijing
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity?byProvinceName= Shanghai
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity?byProvinceName= hubei
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity?byProvinceName= HenanQuery to get this weather forecast Web Services Supported States 、 Information of provinces and cities at home and abroad
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportDataSet
Query to get this weather forecast Web Services Supported States 、 Information of provinces and cities at home and abroad
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportProvince
Query to get the weather conditions in the next three days according to the name of the city or region 、 Now the weather is real 、 Weather and life index
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName= Shenzhen
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=59493
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName= Beijing
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=54511
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName= Shanghai
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=58367
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName= Hong Kong
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=45005
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=Chicago
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=72530
7. Python requests Use
Postman As a tool , Yes UI The tool can be operated completely Web API(Application Programming Interface), Some scenes , You also need to operate in an automated test scenario Web API. about Python There are two main tool operations HTTP Web API.
- urllib (python Self contained , But grammar is anti human )
- requests ( A third party , however HTTP Request for human), We recommend this requests Tools .
and Selenium equally ,requests It is also a third-party tool library . analogy Selenium Operating the browser ,requests operation HTTP request .
Deploy requests The process of
pip install requests
requests There are two common ways
- requests.get()
- requests.post()
Both of the above methods will return one Response Class object . Be careful Response class Belong to requests.
As an automated interface testing tool , Be similar to Selenium, We need to use Page-Object How to design
- Every Page Write a URL The function of .
- get_realtime_weather_by_ip
- get_realtime_weather_by_city
- get_realtime_weather_by_location
- ... Company
- ... Language
- Every page Not at all Direct use requests
- encapsulation requests To box_requests.py
- Create a class , Used to remove from the package box_requests.py Return to our customized result ( Respond to )
- In each use case , Inherit unittest.TestCase, call Page, To test
- The test data should be extracted , Put it in csv perhaps In the database
8. ordinary GET Request instance
- The weather is real
GET/weather/now.json
Get the weather of the specified city . Paying users can access all data , Free users only return the weather phenomenon text 、 Code and temperature 3 Data . notes : Chinese cities do not support cloud cover and dew point temperature .
Request address example
Parameters
key
Yours API secret key
location
The location queried Parameter value range :
City IDfor example :location=WX4FBXXFKE4FChinese name of the cityfor example :location= BeijingCombination of provincial and municipal namesfor example :location= Chaoyang, Liaoning 、location= Beijing chaoyangCity Pinyin / English namefor example :location=beijing( For example, cities with the same phonetic alphabet , You can add provinces and spaces before , example :shanxi yulin)Longitude and latitudefor example :location=39.93:116.40( Latitude before longitude after , Colon separated )IP Addressfor example :location=220.181.111.86( some IP The address may not be able to locate the city )“ip” Two lettersAutomatically identify requests IP Address , for example :location=iplanguage
Language ( Optional ) Parameter value range : Click here to view the
unit
Company ( Optional ) Parameter value range :
cWhen the parameter is c when , temperature c、 The wind speed km/h、 visibility km、 pressure mbfWhen the parameter is f when , temperature f、 The wind speed mph、 visibility mile、 pressure inch The default value is :c
Return results 200
{
"results": [{
"location": {
"id": "C23NB62W20TF",
"name": " Seattle ",
"country": "US",
"timezone": "America/Los_Angeles",
"timezone_offset": "-07:00"
},
"now": {
"text": " cloudy ", // Weather phenomenon text
"code": "4", // Weather phenomenon code
"temperature": "14", // temperature , Unit is c Degrees centigrade or f Fahrenheit
"feels_like": "14", // Body feeling temperature , Unit is c Degrees centigrade or f Fahrenheit
"pressure": "1018", // pressure , Unit is mb HPA or in Inch
"humidity": "76", // Relative humidity ,0~100, The unit is percentage
"visibility": "16.09", // visibility , Unit is km Km or mi miles
"wind_direction": " The northwest ", // Wind text
"wind_direction_degree": "340", // Wind angle , Range 0~360,0 It's due north ,90 It's due east ,180 Due south ,270 It's due west
"wind_speed": "8.05", // The wind speed , Unit is km/h Kilometers per hour or mph Miles per hour
"wind_scale": "2", // Wind power level , Please refer to :http://baike.baidu.com/view/465076.htm
"clouds": "90", // cloudiness , Range 0~100, The percentage of the sky covered by clouds # We don't support Chinese cities right now #
"dew_point": "-12" // Dew point temperature , Please refer to :http://baike.baidu.com/view/118348.htm # We don't support Chinese cities right now #
},
"last_update": "2015-09-25T22:45:00-07:00" // Data update time ( Local time in the city )
}]
}
Specific steps :
encapsulation requests To
box_requests.pyimport requests from model.http_response import HttpResponse class BoxRequests: def get(self, url, param): """ use Get Method request for URL :param url: :param param: Parameters :return: model Medium HttpResponse Class object """ r = requests.get(url, param) http_response = HttpResponse() http_response.status_code = r.status_code http_response.json_dict = r.json() return http_response
Create a folder model, Create a class inside
HttpResponseclass HttpResponse: status_code = None json_dict = None
Create a page :
senivers_realtime_weather_page.pyfrom base.box_requests import BoxRequests class SeniversRealtimeWeatherPage: base_url = "/weather/now.json" def get_weather_by_ip(self, host, api_key): """ according to IP Check the weather where the address is located :param host: :param api_key: :return: Self defined HttpResponse Class object """ br = BoxRequests() # Create a dictionary , Used to transfer parameters param = { "key": api_key, "location": "ip" } # use host and overall situation base_url Piece together URL http_response = br.get(host + self.base_url, param) return http_response
Create a case :
seniverse_api_tests.pyimport unittest from pages.api.senivers_realtime_weather_page import SeniversRealtimeWeatherPage
class SeniverseApiTests(unittest.TestCase):
api_key = None
page = None
host = None
def setUp(self):
self.api_key = "MJX11XSAPG"
self.host = "https://api.seniverse.com/v3"
self.page = SeniversRealtimeWeatherPage()
def test_query_realtime_weather_by_ip(self):
r = self.page.get_weather_by_ip(self.host, self.api_key)
self.assertEqual(200, r.status_code, " The status code returned incorrectly !")
expected_city = " Shenzhen "
actual_city = r.json_dict["results"][0]["location"]["name"]
self.assertEqual(expected_city, actual_city, " City name and ip Not in conformity with ")
if name == "main":
unittest.main()
## 9. ordinary POST Request instance
1. encapsulation Requests.post() Method
1. Pass on url
2. Pass on data
3. Pass on headers
2. establish PingChargeCreatePage class
1. create()
2. ...
3. establish Use cases
Examples are as follows :
### establish Charge object
request :POST `https://api.pingxx.com/v1/charges`
To initiate a payment request, you need to create a new `charge` object , Obtain an available payment voucher for the client to initiate a payment request to a third-party channel . If using test mode API Key, There will be no real transaction . When payment is successful ,Ping++ Will send Webhooks notice .
| Request parameters | |
| ------------------------------------ | ---------------------------------------- |
| order_no**REQUIRED** | Merchant order number , Adapt to the requirements of each channel for this parameter , Must be unique within the merchant system .( `alipay` : 1-64 position , `wx` : 2-32 position , `bfb` : 1-20 position , `upacp` : 8-40 position , `yeepay_wap` :1-50 position , `jdpay_wap` :1-30 position , `qpay` :1-30 position , `cmb_wallet` :10 Bit pure numeric string . notes : except `cmb_wallet` It is recommended to use other channels besides 8-20 position , Numbers or letters are required , Special characters are not allowed ). |
| app [ id ]**EXPANDABLE****REQUIRED** | Used for payment `app` Object's `id` , `expandable` Expandable , see [ How to get App ID](https://help.pingxx.com/article/198599) . |
| channel**REQUIRED** | Third party payment channels used for payment . Reference resources [ Payment channel attribute value ](https://www.pingxx.com/api#%E6%94%AF%E4%BB%98%E6%B8%A0%E9%81%93%E5%B1%9E%E6%80%A7%E5%80%BC) . |
| amount**REQUIRED** | Total order amount ( Must be greater than 0), The unit is the minimum monetary unit of the corresponding currency , RMB is divided into . If the total amount of the order is 1 element , `amount` by 100, Please check the range of the loan amount applied for by the loan merchant . |
| client_ip**REQUIRED** | The client that initiated the payment request IPv4 Address , Such as : 127.0.0.1. |
| currency**REQUIRED** | Three place ISO Currency code , Currently only RMB is supported `cny` . |
| subject**REQUIRED** | The title of the commodity , The maximum length of this parameter is 32 individual Unicode character , UnionPay Omni channel ( `upacp` / `upacp_wap` ) Restriction on 32 Bytes . |
| body**REQUIRED** | Description of the product , The maximum length of this parameter is 128 individual Unicode character ,yeepay_wap For this parameter, the length is limited to 100 individual Unicode character . |
| extra*optional* | Additional parameters required when a transaction is initiated by a specific channel , And the additional parameters returned by the successful payment of some channels , A detailed reference [ Payment channel extra Parameter description ](https://www.pingxx.com/api#%E6%94%AF%E4%BB%98%E6%B8%A0%E9%81%93-extra-%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E) . |
| time_expire*optional* | Order expiration time , use Unix A time stamp indicates . The time range is... After the order is created 1 Minutes to 15 God , The default is 1 God , Create time to Ping++ Server time shall prevail . The valid value of wechat for this parameter is limited to 2 Within hours ; The valid value of UnionPay for this parameter is limited to 1 Within hours . |
| metadata*optional* | Reference resources [ Metadata ](https://www.pingxx.com/api#%E5%85%83%E6%95%B0%E6%8D%AE) . |
| description*optional* | Additional instructions to the order , most 255 individual Unicode character . |
** return **
Return a payment voucher `charge` object . Whereas the payment channel is for `order_no` The legitimacy of , To ensure the correct processing of payment requests , Please make sure that for the same payment channel , Between different payment products `order_no` Uniqueness . for example : Has been used under wechat official account `order_no` It cannot be reused under wechat payment and wechat official account scanning , This rule also applies to other similar channels . If an error occurs , Error code and error details will be returned , See [ error ](https://www.pingxx.com/api#%E9%94%99%E8%AF%AF).
according to Postman Execution of this test . Select the following data :
- headers
- data:params
Put the above two data , become Python The dictionary is passed to requests.post() in ,
Check... In the resulting response Json The value of the object .
1. modify box_requests, add to post_json Method
```python
def post_json(self, url, data=None, json=None, **kwargs):
"""
use POST Method request for URL
:param url:
:param data: Data submitted
:param json: The submitted json ( Optional )
:param kwargs: Additional parameters
:return:
"""
r = requests.post(url, data, json, **kwargs)
http_response = HttpResponse()
http_response.status_code = r.status_code
http_response.json_dict = r.json()
return http_response
establish page, Serve test cases
class PingxxChargeCreatePage: base_url = "/charges" def create_charge(self, host, data, headers): br = BoxRequests() # use host and overall situation base_url Piece together URL http_response = br.post_json(host + self.base_url, data=data, headers=headers) return http_response
establish test_case
import unittest from pages.api.pingxx_charge_create_page import PingxxChargeCreatePage class PingxxApiTests(unittest.TestCase): test_secret_key = None app_id = None page = None host = None def setUp(self): self.app_id = "app_rfv1SGmPKijLnPef" self.test_secret_key = "c2tfdGVzdF80bXpqelRpenpQQ0NqVEt5VEN5VGVqYlA6" self.host = "https://api.pingxx.com/v1" self.page = PingxxChargeCreatePage() def test_create_charge_by_wechat(self): data = { "order_no": "88888888666666664444444422222222", "app[id]": self.app_id, "channel": "wx", "amount": 10000000, "client_ip": "192.168.1.202", "currency": "cny", "subject": "iphone 999 Genuine goods ", "body": " Regular parallel goods iphone 8 1000 platform ", "description": "iphone 8 A dozen .... Additional instructions to the order , most 255 individual Unicode character ." } headers = {"Authorization": "Basic %s" % self.test_secret_key} r = self.page.create_charge(self.host, data, headers) self.assertEqual(200, r.status_code, " The status code returned incorrectly !") expected_object = "charge" actual_object = r.json_dict["object"] self.assertEqual(expected_object, actual_object, " Check whether the object is payment failed !")
if __name__ == "__main__":
unittest.main()
```
from :https://www.jianshu.com/p/4a386d57dd72
source : Simple books
边栏推荐
- Maze walking
- From query database performance optimization to redis cache - talk about cache penetration, avalanche and breakdown
- Loss function of depth model
- 2022年电气试验考试试题模拟考试平台操作
- JSON basic syntax
- halcon之区域:多种区域(Region)生成(4)
- **MySQL example 1 (query by multiple conditions according to different problems)**
- shell正则表达式
- Summary of knowledge points of catboost
- 图文大师印章简易制作
猜你喜欢

CityJSON

Viwi interface

GNN (graph neural network) introduction vernacular

RT thread project engineering construction and configuration - (Env kconfig)

15 `bs object Node name Node name String` get nested node content

Cross validation -- a story that cannot be explained clearly
![[Excel知识技能] Excel数据类型](/img/f6/e1ebe033d1a2a266ebda00b10098ed.png)
[Excel知识技能] Excel数据类型

生信周刊第33期

RT-Thread 项目工程搭建和配置--(Env Kconfig)

Shell regular expression
随机推荐
--SQL of urban cultivation manual -- Chapter 1 basic review
Rollback Protection
大周建议自媒体博主前期做这4件事
2022资料员-通用基础(资料员)考试模拟100题及在线模拟考试
RT thread project engineering construction and configuration - (Env kconfig)
浅谈接口测试(二)
木瓜蛋白酶的特点及相关特异性介绍
Flex & bison start
Loss function of depth model
Oracle数据库完全卸载步骤(暂无截图)
Common basic Oracle commands
Technical foreword - metauniverse
Accumulation and summary of activation function
Procédure de désinstallation complète de la base de données Oracle (pas de capture d'écran)
web测试
Etcd database source code analysis cluster communication initialization
15 `bs对象.节点名称.节点名称.string` 获取嵌套节点内容
2022年育婴员(五级)考试试题及答案
Perfdog
Shengxin weekly issue 33





































