当前位置:网站首页>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 :

  1. Web The interface test ,
  2. Application program interface (API, application programming interface) test ,
  3. 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

  1. download Postman Installation package , It is divided into 32 position and 64 position .https://www.getpostman.com

  2. install Postman

  3. Registered users (Sign Up) And login (Sign In)

    Snap23.png

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

    Snap24.png

  5. 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_idfirst_namelast_nameemailphone_numberhire_datejob_idsalary
100StevenKingSKING515.123.45676/17/1987AD_PRES24000
101NeenaKochharNKOCHHAR515.123.45689/21/1989AD_VP17000

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

  1. Method:GET POST PUT DELETE
  2. URL: The address of the interface
  3. 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
  1. 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
  1. The actual object of the interface : data

    1. The format of the data
    2. Content of data

4. Postman Use

  1. test Knowing weather API:https://www.seniverse.com/

    1. Sign in Knowing weather ( To register first )

    2. 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
    3. With Get real-time weather as an example :

      1. API Methods and URL:GET, https://api.seniverse.com/v3/weather/now.json

      2. API Parameters of :

        1. Request parameters :

          Parameter name Parameter type Parameter meaning Whether the choice
          keystring Yours API secret key true
          locationstring The geographical location of the query true
          languagestring The language of the result representation false, Default simplified Chinese
          unitstring The unit in which the result is expressed ( Fahrenheit , Centigrade )false, Default Celsius
        2. 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  
        3. use Postman Start testing

          1. new tab Input in The way , and URL

          2. Click on Params Set parameters

          3. Click on send Start sending requests

          4. 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"
                }
              ]
            }
            

          5. edit Tests page , Add assertions .

            var jsonData = JSON.parse(responseBody);
            tests[" Check city name "] = jsonData.results[0].location.name === "Shenzhen";
            
  2. Use Postman Log in to the natural system , Test the login interface

    1. Use natural 4.2 Or above

    2. 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;
      
    3. restart Apache

    4. open Chrome, Enter the URL of ran , Open login page

      Chrome Open login page

    5. open Fiddler, And set up Chrome Carry out the bag

    6. stay Chrome Log in , Submit username and password

    7. stay Fiddler Capture the login just now in POST request

      Fiddler Capture packets and log in POST

    8. open Postman, newly build URL,POST Method .

      Need to set up Postman, Click on File | Settings, Set it up

      settings

      Setting 2

    9. stay Postman Enter just now Fiddler Requested POST Of URL

      Fiddler Caught analysis

      Enter the above URL

      URL

    10. 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

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

      Input Body

    2. 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;
      
    3. stay Chrome Log out of , Note that this step is important , Only after you exit can you Postman Sign in

      sign out Of course

    4. stay Postman Click on the Send, To test

      test result

    5. see Postman Results of operation .

      result.png

5. Web Interface authentication

Web Preparation of interface test

  1. HTTP Protocol request and response
    request :GET/POST
    Respond to :html/JSON/XML/CSS/JavaScript/png..
  2. The concept of testing
    Assertion : Check the contents of the returned response .
    Test design : Design the use case according to the requested parameters
  3. Read the interface documentation
    The way of request and URL
    Request parameters and response parameters
  4. 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 :

  1. open https://www.pingxx.com/ Ping++ Online payment website , Create an account , And login , An application will be created automatically .

    Snap27.png

  2. Enter the automatically created application , Enter the application control panel interface .

  3. obtain APP[id], Get... As shown in the figure , And use it later

    Snap28.png

  4. obtain Test Secret Key, Get... As shown in the figure , And still wait to use

    Snap29.png

    Snap30.png

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

    Snap31.png

     

    Snap32.png

     

    Snap33.png

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

    Snap34.png

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

    Snap35.png

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

    Snap36.png

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

    Snap37.png

     

    Snap38.png

  10. 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

  1. Click on Send Start testing .

    Snap40.png

  • Example 2: Create a red envelope Web The interface test
  1. Interface description of wechat red packet payment interface test

    Create a red envelope Web Interface description

  2. stay Postman Input in POST Methods and URL

    Paste_Image.png

  3. 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

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

    enter text

  5. 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;
    

  6. Click on Send, Check .

    result

  7. 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

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

  1. requests.get()
  2. 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

https://api.seniverse.com/v3/weather/now.json?key=MJX11XSAPG&location=beijing&language=zh-Hans&unit=c

Parameters

  • key

    Yours API secret key

  • location

    The location queried Parameter value range : City ID for example :location=WX4FBXXFKE4F Chinese name of the city for example :location= Beijing Combination of provincial and municipal names for example :location= Chaoyang, Liaoning 、location= Beijing chaoyang City Pinyin / English name for example :location=beijing( For example, cities with the same phonetic alphabet , You can add provinces and spaces before , example :shanxi yulin) Longitude and latitude for example :location=39.93:116.40( Latitude before longitude after , Colon separated )IP Address for example :location=220.181.111.86( some IP The address may not be able to locate the city )“ip” Two letters Automatically identify requests IP Address , for example :location=ip

  • language

    Language ( Optional ) Parameter value range : Click here to view the

  • unit

    Company ( Optional ) Parameter value range :c When the parameter is c when , temperature c、 The wind speed km/h、 visibility km、 pressure mbf When 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.py

    import 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 HttpResponse

    class HttpResponse:
        status_code = None
        json_dict = None
    

  • Create a page :senivers_realtime_weather_page.py

    from 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.py

    import 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
  1. 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
    

  2. 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
 

 



 

原网站

版权声明
本文为[NitefullSand]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206252353542694.html