コード例 #1
0
 def setUp(self) -> None:
     # 登录
     self.method = "post"
     url = "http://ecshop.itsoso.cn/ECMobile/?url=/user/signin"
     data = {"name": "test", "password": "******"}
     response = Interface.common_method(method=self.method, url=url, data=data)
     self.sid = get_result_for_keyword(response, "sid")  # 获取登录返回值的sid
     self.uid = get_result_for_keyword(response, "uid")  # 获取登录返回值的uid
コード例 #2
0
    def test_cart(self):
        """
        添加商品到购物车
        :return:
        """
        url = "http://ecshop.itsoso.cn/ECMobile/?url=/cart/create "
        data = {"spec": [], "session": {"uid": f"{self.uid}", "sid": f"{self.sid}"}, "goods_id": 72, "number": 1}
        response = Interface.common_method(method=self.method, url=url, data=data)
        print(response)

        """购物车清单(列表)"""
        url = "http://ecshop.itsoso.cn/ECMobile/?url=/cart/list"
        data = {"session": {"uid": f"{self.uid}", "sid": f"{self.sid}"}}
        response = Interface.common_method(method=self.method, url=url, data=data)
        # self.rec_id = get_result_for_keyword(response, "rec_id")
        print(response)

        """确认订单 """

        url = "http://ecshop.itsoso.cn/ECMobile/?url=/flow/checkOrder"
        data = {"session": {"uid": f"{self.uid}", "sid": f"{self.sid}"}}
        response = Interface.common_method(method=self.method, url=url, data=data)

        print(response)

        """提交订单"""
        url = "http://ecshop.itsoso.cn/ECMobile/?url=/flow/done "
        data = {"shipping_id": "6", "session": {"uid": f"{self.uid}", "sid": f"{self.sid}"}, "pay_id": "5"}
        response = Interface.common_method(method=self.method, url=url, data=data)
        global order_id
        order_id = get_result_for_keyword(response, "order_id")
        print(order_id)
        print(response)

        """订单支付"""
        url = "http://ecshop.itsoso.cn/ECMobile/?url=/order/pay "
        data = {"session": {"uid": f"{self.uid}", "sid": f"{self.sid}"}, "order_id": f"{order_id}"}
        response = Interface.common_method(method=self.method, url=url, data=data)
        status = Interface.status(response)
        print(response)
        self.assertTrue(status == 1)
コード例 #3
0
 def test_register(self, data):
     req_data = {
         "field": [{
             "id": 5,
             "value": data['mobile']
         }],
         "email": data['email'],
         "name": data['name'],
         "password": data['password']
     }
     response = Interface.common_method(method=self.method,
                                        url=self.url,
                                        data=req_data)
     print(response)
     status = get_result_for_keyword(response, "succeed")
     # db = Database(password="******", database="ecshop")
     # sql = "select * from ecs_users where user_name = %s"
     # cont = data["name"]
     # args = [cont]
     # content = db.one(sql, args)
     # res = content["user_name"]
     self.assertEqual(status, data['expect'])