Exemplo n.º 1
0
    def test_update_product(self):
      token = Token.Token()
      conf = Config()
      data = Update()
      test = Assert.Assertions()

      host = conf.host_test
      req_url = 'http://' + host
      urls = req_url + data.url[0]
      products = data.data
      token = token.get_token("test")
      header = data.header
      header[0].update(token)

      response = requests.post(urls,data=json.dumps(products[0]), headers=header[0])
      print(response)
      print("------------------我是可爱的分界线----------------------------")
      r_data = response.json()

    # 断言
      allure.attach('实际结果', '{}'.format(r_data))
      assert test.assert_code(response.status_code, 200)
      assert test.assert_body(r_data,"message","update product success")

      Consts.RESULT_LIST.append('True')
Exemplo n.º 2
0
    def test_get_pro(self):
        """
           用例描述:获取商品列表
        :return:
        """
        token = Token.Token()
        conf = Config()
        data = Product()
        test = Assert.Assertions()

        host = conf.host_test
        req_url = 'http://' + host
        urls = req_url + data.url[0]
        headers = token.get_token("test")
        shop_id = data.data
        params = urls + "?" + "shop_id=" + str(shop_id[0])

        response = requests.get(params, headers=headers)
        print("------------------我是可爱的分界线----------------------------")
        r_data = response.json()

        # 断言
        allure.attach('实际结果', '{}'.format(r_data))
        assert test.assert_code(response.status_code, 200)
        assert test.assert_body_key(r_data, 'data')
        assert test.assert_body_key(r_data, 'page')
        assert test.assert_body_key(r_data, 'size')
        assert test.assert_body_key(r_data, 'total')

        Consts.RESULT_LIST.append('True')
Exemplo n.º 3
0
    def __init__(self):
        """
        :param env.ini:
        """

        self.token = Token.get_token()
        print(self.token)
        self.headers = {
            "User-Agent":
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            "Content-Type": "application/json",
            "X-Auth-Token": self.token
        }
Exemplo n.º 4
0
    def test_get_pro_details(self):
        token = Token.Token()
        conf = Config()
        data = Details()
        test = Assert.Assertions()

        host = conf.host_test
        req_url = 'http://' + host
        urls = req_url + data.url[0]
        headers = token.get_token("test")
        product_id = data.data
        params = urls + "/" + str(product_id[0])

        response = requests.get(params, headers=headers)
        print(response)
        print("------------------我是可爱的分界线----------------------------")
        r_data = response.json()

        # 断言
        allure.attach('实际结果', '{}'.format(r_data))
        assert test.assert_code(response.status_code, 200)
        assert test.assert_body_key(r_data, 'data')

        Consts.RESULT_LIST.append('True')
Exemplo n.º 5
0
 def __init__(self, env):
     self.token = Token.Token()
     self.get_token = self.token.get_token(env)
Exemplo n.º 6
0
# @Time    : 2019/9/10 21:34
# @Author  : mrwuzs
# @Site    :
# @File    : Request.py
# @Software: PyCharm
"""
封装request
"""

import requests
import Common.Consts
import json

from Common import Token

Token = Token.Token()


class Request:
    def __init__(self):
        """
        :param env.ini:
        """

        self.token = Token.get_token()
        print(self.token)
        self.headers = {
            "User-Agent":
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
            "Content-Type": "application/json",
            "X-Auth-Token": self.token