Esempio n. 1
0
 def test_market_history(self):
     """获取K线数据接口"""
     serverc = "market/history"
     data = {
         "symbol": self.symbol,
         "from": DKApiBase().time2Timestamps(self.fromdate),  # 开始时间戳
         "to": DKApiBase().nowtime2Timestamps(),  # 截至时间戳
         "resolution": "15"  # K线类型:1=1分/5=5分/15=15分/30=30分/1h=小时/1d=天/1m=月
     }
     r = request2DKApi(serverc, data).send()
     print(r)
     self.assertIsNotNone(r[2], "返回数据为空")
Esempio n. 2
0
    def test_otc_order_cancel_buy(self):
        """买币取消订单"""

        # # 查询账户余额及冻结余额
        # try:
        #     check_mysql = connect_mysql().connect2mysql(self.inquire_member_wallet_CNYT_sql)
        #     parameter_name = ["coin_id", "balance", "frozen_balance", "lock_balance"]  # 查询字段名称拼装成字典形式内容
        #     before_member_wallet = DKApiBase().mysqlResultFormat(check_mysql, parameter_name)
        #     # print(before_member_wallet)
        #     before_Silubium_balance = before_member_wallet[0]["balance"]  # 变动前slb余额
        #     before_Silubium_frozen_balance = before_member_wallet[0]["frozen_balance"]  # 变动前slb冻结余额
        #     berore_USDT_balance = before_member_wallet[1]["balance"]  # 变动前USDT余额
        # except Exception as e:
        #     print("账户信息查询出错{}".format(e))

        # 查询可用c2c卖出USDT广告
        try:
            using_advertise = connect_mysql().connect2mysql(
                self.Inquire_advertise_sql_sale)
            # 处理查询结果
            parameter_name = [
                "id", "advertise_type", "max_limit", "min_limit",
                "remain_amount", "price", "coin_id", "member_id"
            ]
            advertise_data = DKApiBase().mysqlResultFormat(
                using_advertise, parameter_name)[0]
        except Exception as e:
            print("可用C2C广告信息查询出错{}".format(e))
            self.assertTrue(False, "查询可用广告失败")

        # 用户买入订单
        server = "otc/order/buy"
        data = {
            "id": advertise_data["id"],  # 广告id
            "coinId": advertise_data["coin_id"],  # 币种id,otc_coin表ID
            "price": advertise_data["price"],  # 当前价格
            "money": self.amount * advertise_data["price"],  # 金额
            "amount": self.amount,  # 数量
            "remark": "自动脚本测试买币",  # 要求、备注,非必传
            "mode": ""  # 计算方式,金额/价格=数量为0,数量*价格=金额为1,非必传,默认为0
        }
        r_cancel_buy = request2DKApi(server, data, self.header).send()
        print(r_cancel_buy)

        # 用户取消买入订单
        orderSn_cancel_buy = DKApiBase().str2json(
            r_cancel_buy[2])["data"]  # 下单结果获取交易订单号
        server = "otc/order/cancel"
        data = {"orderSn": orderSn_cancel_buy}
        r_cancel = request2DKApi(server, data, self.header).send()
        print(r_cancel)
        self.assertRegexpMatches(r_cancel[2], '"message" : "取消成功"', "结果断言失败")
Esempio n. 3
0
 def market_history(self):
         """
         9、获取K线数据接口
         :return: 
         """
         fromdate = "2018-07-26 00:00:00"
         # todate = "2018-07-24 00:00:00"
         serverc = "market/history"
         data = {"symbol":"SLB/USDT",
                 "from":DKApiBase().time2Timestamps(fromdate),  # 开始时间戳
                 "to":DKApiBase().nowtime2Timestamps(),  # 截至时间戳
                 "resolution":"1"  # K线类型:1=1分/5=5分/15=15分/30=30分/1h=小时/1d=天/1m=月
                 }
         r = request2DKApi(serverc, data).send()
         print(r)
Esempio n. 4
0
 def otc_advertise_create(self):
     """
     1.1 创建广告
     :return: 
     """
     jyPassword = "******"
     server = "otc/advertise/create"
     data = {
         "price": "1",
         "advertiseType": "1",  # 0买,1卖
         "coin.id": "13",
         "minLimit": "100",
         "maxLimit": "1000",
         "timeLimit": "30",
         "country": "中国",
         "priceType": "0",
         "premiseRate": "",
         "remark": "测试广告,自动化脚本添加",
         "number": "1000",
         "pay[]": "银联",
         "auto": "1",  # 是否开启自动回复0否1是,默认否
         "autoword": "先付款,后放币",
         "needBindPhone": "1",  # 是否需要交易方已绑定手机号,0:不需要,1:需要
         "needRealname": "1",  # 是否需要交易方已做实名认证,0:不需要,1:需要
         "needTradeTimes": "10",  # 需要交易方至少完成过N笔交易(默认为0)
         "needPutonDiscount": "1",  # 是否使用优惠币种支付,0:不使用,1:使用
         "bindingResult": "",  # 绑定结果,非必传项
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(
         server,
         data,
     ).send()
     print(r)
Esempio n. 5
0
 def guess_api_guessActivity_betting(self):
     """
     投票活动
     :return: 
     """
     server = "guess-api/guessActivity/betting"
     platformPassword = "******"
     header = [{
         "access-auth-token":
         "d809615e96176085a1152f74c8a47b78800141539678969628"
     }, {
         "access-auth-token": "f2794f54e17720d34aa505e3556724f3"
     }, {
         "access-auth-token": "492675514ec5f4d8ee249f26b15a4746"
     }]
     for i in range(0, 20):
         for hd in header:
             data = {
                 "periodId":
                 "8",  # 期数id
                 "coinNum":
                 "11",  # 投注数
                 "rangeId":
                 "25",  # 投注区间范围id
                 "jyPassword":
                 DKApiBase().getSign(platformPassword +
                                     "hello, moto"),  # 资金密码
                 "useSms":
                 "0"  # 是否用短信0否,1是
             }
             r = request2DKApi(server, data, hd).send()
             print(r)
Esempio n. 6
0
 def test_exchange_order_add_detail(self):
     """委托and交易撮合and查询委托成交明细"""
     # 添加买入委托订单
     serverc = "exchange/order/add"
     data = {
         "symbol": self.symbol,
         "price": "0.08",
         "amount": "100",
         "direction": "0",  # 买卖方向,0=BUY(买)/1=SELL(卖)
         "type": "1"  # 交易类型,1=LIMIT_PRICE(限价交易)
     }
     r = request2DKApi(serverc, data).send()
     print(r)
     # 添加卖出委托订单
     data_sell = {
         "symbol": self.symbol,
         "price": "0.08",
         "amount": "100",
         "direction": "1",  # 买卖方向,0=BUY(买)/1=SELL(卖)
         "type": "1"  # 交易类型,1=LIMIT_PRICE(限价交易)
     }
     r_transaction = request2DKApi(serverc, data_sell).send()
     print(r_transaction)
     # 查询委托订单成交明细
     orderId = DKApiBase().str2json(r_transaction[2])["data"]["orderId"]
     # print(orderId)
     serverc = "exchange/order/detail/" + orderId
     time.sleep(3)  # 等待订单后台撮合成功
     r_detail = request2DKApi(serverc).send()
     print(r_detail)
     self.assertRegexpMatches(r_detail[2], orderId, "结果断言失败")
Esempio n. 7
0
 def otc_advertise_update(self):
     """
     1.5 修改广告
     :return: 
     """
     jyPassword = "******"
     server = "otc/advertise/update"
     data = {
         "id": "94",
         "advertiseType": "1",
         "price": "6.82",
         "coin.id": "1",
         "minLimit": "100",
         "maxLimit": "1000",
         "timeLimit": "20",
         "country": "中国",
         "priceType": "0",
         "premiseRate": "",
         "remark": "备注信息",
         "number": "100000",
         "pay[]": "支付宝",
         "auto": "1",
         "autoword": "自动回复",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 8
0
 def uc_login(self):
         """
         1、登录接口
         :return: 
         """
         serverc = "uc/login"
         platformPassword = "******"
         data = {"username":"******",
                 "password":DKApiBase().getSign(platformPassword + "hello, moto")}
         r = request2DKApi(serverc, data).send()
         print(r)
Esempio n. 9
0
    def test_otc_order_cancel_sale(self):
        """卖币取消订单"""

        # 查询可用c2c买入USDT广告
        try:
            using_advertise = connect_mysql().connect2mysql(
                self.Inquire_advertise_sql_buy)
            # 处理查询结果
            parameter_name = [
                "id", "advertise_type", "max_limit", "min_limit",
                "remain_amount", "price", "coin_id", "member_id"
            ]
            advertise_data = DKApiBase().mysqlResultFormat(
                using_advertise, parameter_name)[0]
        except Exception as e:
            print("可用C2C广告信息查询出错{}".format(e))
            self.assertTrue(False, "查询可用广告失败")

        # 用户卖出订单
        server = "otc/order/sell"
        data = {
            "id": advertise_data["id"],  # 广告id
            "coinId": advertise_data["coin_id"],  # 币种id,otc_coin表ID
            "price": advertise_data["price"],  # 当前价格
            "money": advertise_data["price"] * self.amount,  # 金额
            "amount": self.amount,  # 数量
            "remark": "测试卖币",  # 要求、备注,非必传
            "mode": ""  # 计算方式,金额/价格=数量为0,数量*价格=金额为1,非必传,默认为0
        }
        r_cancel_sale = request2DKApi(server, data, self.header).send()
        print(r_cancel_sale)

        # 用户取消买入订单(发起买入USDT的商家)
        orderSn_cancel_sale = DKApiBase().str2json(
            r_cancel_sale[2])["data"]  # 下单结果获取交易订单号
        server = "otc/order/cancel"
        data = {"orderSn": orderSn_cancel_sale}
        r_cancel = request2DKApi(server, data).send()
        print(r_cancel)
        self.assertRegexpMatches(r_cancel[2], '"message" : "取消成功"', "结果断言失败")
Esempio n. 10
0
 def uc_approve_update_transaction_password(self):
     """
             4.7 修改资金密码(修改第一次成功,修改后的继续修改报资金密码错误)(建议手动回归验证)
             :return: 
             """
     oldPassword = "******"
     server = "uc/approve/update/transaction/password"
     data = {
         "oldPassword": DKApiBase().getSign(oldPassword + "hello, moto"),
         "newPassword": "******"
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 11
0
 def test_otc_advertise_all(self):
     """个人所有广告and广告详情"""
     # 所有广告
     serverc = "otc/advertise/all"
     r = request2DKApi(serverc).send()
     print(r)
     # 广告详情
     serverc = "otc/advertise/detail"
     data = {"id": str(DKApiBase().str2json(r[2])["data"][0]["id"])}
     r_detail = request2DKApi(serverc, data).send()
     print(r_detail)
     self.assertRegexpMatches(r_detail[2], '"message" : "SUCCESS"',
                              "结果断言失败")
Esempio n. 12
0
        def uc_activity_joinStoLock(self):
                """
                @description: CNYT锁仓,模拟多个用户锁仓
                :return: 
                """
                user_mobile = ["17700000020", "17700000021"]
                for username in user_mobile:
                        server = "uc/login"
                        data = {"username": username,
                                "password": DKApiBase().getSign("cs111111" + "hello, moto"),
                                "type": 0}
                        r = request2DKApi(server, data).send()
                        print(r)

                        serverc = "uc/activity/joinStoLock"
                        jyPassword = "******"
                        header = {"access-auth-token": "{}".format(username)}
                        data = {"id":"50",
                                "cnyAmount":"1000",
                                "jyPassword":DKApiBase().getSign(jyPassword + "hello, moto")}
                        r = request2DKApi(serverc, data, header).send()
                        print(r)
Esempio n. 13
0
 def uc_approve_cancel_business(self):
     """
             4.24 申请取消认证商家(待调试)
             :return: 
             """
     jyPassword = "******"
     server = "uc/approve/cancel/business"
     data = {
         "reason": "申请退保原因",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 14
0
 def uc_activity_unLockActivity(self):
     """
             1.6、用户手动申请解锁锁仓活动
             :return: 
             """
     jyPassword = "******"
     server = "uc/activity/unLockActivity"
     data = {
         "id": "508",  # 锁仓详情主键
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 15
0
    def setUpClass(cls):
        # @classmethod修饰setUpClass(cls):类方法,让setUpClass(cls):只需要执行一次,setUp(self)则会在每一个def test_*(self)开始前执行
        # 如setUpClass(cls):抛出异常则不会执行tearDownclass(cls):

        # 预定义的参数
        cls.symbol = "SLU"  # 币种名称
        cls.symbol_base = "USDT"  # 基币名称

        # 获取活动查询结果
        try:
            cls.activitie_id_sql = """SELECT id, `name`, activitie_id FROM lock_coin_activitie_setting WHERE coin_symbol = 'SLU' AND damages_calc_type = 1 ORDER BY id DESC;"""
            cls.activitie_result = DKApiBase().mysqlResultFormat(connect_mysql().connect2mysql(cls.activitie_id_sql), ["id", "name", "activitie_id"])
        except Exception as e:
            print("数据库查询错误:{}".format(e))

        # 查询用户全部锁仓记录
        try:
            cls.LockCoin_sql = """SELECT id, coin_unit, member_id, type, `status` FROM lock_coin_detail 
            WHERE coin_unit = 'SLU' AND member_id = (SELECT id FROM member WHERE token = '{}') ORDER BY id DESC;""".format(COMMON_TOKEN)
            cls.LockCoin_result = DKApiBase().mysqlResultFormat(connect_mysql().connect2mysql(cls.LockCoin_sql), ["id", "coin_unit", "member_id", "type", "status"])
        except Exception as e:
            print("数据库查询错误:{}".format(e))
Esempio n. 16
0
 def uc_login(self):
     """
             14 登录
             14.1 登录
             :return: 
             """
     server = "uc/login"
     data = {
         "username": "******",
         "password": DKApiBase().getSign("cs111111" + "hello, moto"),
         "type": 0
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 17
0
 def otc_order_release(self):
     """
     3.8 订单放行(由卖方发起放行,买币由商家发起方形、卖币由用户发起放行)
     :return: 
     """
     jyPassword = "******"
     header = {"access-auth-token": "7d614fe74466a03ca3c8e7522321b2b3"}
     server = "otc/order/release"
     data = {
         "orderSn": "81395587148288000",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data, header).send()
     print(r)
Esempio n. 18
0
 def uc_activity_joinQuantifyLock(self):
     """
             1.14 参加SLB节点产品
             :return: 
             """
     jyPassword = "******"
     server = "uc/activity/joinQuantifyLock"
     data = {
         "id": "46",  # 活动ID
         "cnyAmount": "10000",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 19
0
 def uc_activity_joinFinancialLock(self):
     """
             1.7 参加理财锁仓活动
             :return: 
             """
     jyPassword = "******"
     server = "uc/activity/joinFinancialLock"
     data = {
         "id": "46",
         "usdtNum": "100",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 20
0
 def uc_activity_joinActivity(self):
     """
             1.5、参加锁仓活动
             :return: 
             """
     jyPassword = "******"
     server = "uc/activity/joinActivity"
     data = {
         "id": "46",  # 锁仓活动配置表主键
         "boughtAmount": "10",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 21
0
 def uc_activity_autoUnLockFinancialLock(self):
     """
             SLB理财解锁接口
             :return: 
             """
     jyPassword = "******"
     server = "uc/activity/autoUnLockFinancialLock"
     data = {
         "id": "",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto"),
         "settlementType": ""  # 0为SLB解锁,1为USDT
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 22
0
 def uc_activity_unLockFinancialLock(self):
     """
             1.8 用户手动申请解锁理财锁仓活动
             :return: 
             """
     jyPassword = "******"
     server = "uc/activity/unLockFinancialLock"
     data = {
         "id": "509",  # 锁仓详情主键
         "settlementType": "1",  # 理财结算类型:0:活动币种结算;1:USDT结算
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto")
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 23
0
    def setUpClass(cls):
        cls.jyPassword = DKApiBase().getSign("111111" +
                                             "hello, moto")  # 用户资金密码
        cls.advertcoin_CNYT = "CNYT"  # 广告币种
        cls.walletcion_SLU = "SLU"  # 钱包账户币种
        cls.advertPrice_USDT = 6.85  # 广告USDT价格
        cls.advertPrice_CNYT = 1  # 广告USDT价格
        cls.otc_coin_id_USDT = 2  # otc_coin表币种ID
        cls.otc_coin_id_CNYT = 13  # otc_coin表币种ID
        cls.otc_number = 1000
        cls.header = {
            "access-auth-token": COMMON_TOKEN_ANOTHER
        }  # c2c交易用户token,买币的用户需要开通支付方式
        cls.header_general = {
            "access-auth-token": COMMON_TOKEN_GENERAL_USER
        }  # c2c非认证商家广告方
        cls.header_general_user = {
            "access-auth-token": COMMON_TOKEN_GENERAL_USER_ANOTHER
        }  # c2c非认证商家交易方
        cls.amount = 100  # 交易数量

        # 查询商家认证状态
        cls.member_level_sql = '''SELECT member_level FROM member WHERE token = '{}';'''.format(
            COMMON_TOKEN_ANOTHER)

        # 查询商家钱包账户数据-CNYT
        cls.inquire_Merchant_wallet_CNYT_sql = '''SELECT coin_id, balance, frozen_balance, lock_balance 
        FROM member_wallet 
        WHERE member_id = (SELECT id FROM member WHERE token = '{}') AND coin_id = 'CNYT';'''.format(
            COMMON_TOKEN)
        # 查询商家钱包账户数据-SLU
        cls.inquire_Merchant_wallet_SLU_sql = '''SELECT coin_id, balance, frozen_balance, lock_balance 
        FROM member_wallet 
        WHERE member_id = (SELECT id FROM member WHERE token = '{}') AND coin_id = 'SLU';'''.format(
            COMMON_TOKEN)

        # 查询用户钱包账户数据
        cls.inquire_member_wallet_CNYT_sql = '''SELECT coin_id, balance, frozen_balance, lock_balance 
        FROM member_wallet 
        WHERE member_id = (SELECT id FROM member WHERE token = '{}') AND coin_id = 'CNYT';'''.format(
            COMMON_TOKEN_ANOTHER)

        # 查询可用C2C卖出USDT广告
        cls.Inquire_advertise_sql_sale = '''SELECT id, advertise_type, max_limit, min_limit, remain_amount, price, coin_id, member_id 
        FROM advertise 
        WHERE member_id = '74773' AND coin_id = 2 AND `status` = 0 AND advertise_type = 1;'''

        # 查询可用C2C买入USDT广告
        cls.Inquire_advertise_sql_buy = """SELECT id, advertise_type, max_limit, min_limit, remain_amount, price, coin_id, member_id 
Esempio n. 24
0
 def uc_approve_update_bank(self):
     """
             4.16 更改银行卡
             :return: 
             """
     jyPassword = "******"
     server = "uc/approve/update/bank"
     data = {
         "bank": "中国工商银行",
         "branch": "沙坪坝支行",
         "jyPassword": DKApiBase().getSign(jyPassword + "hello, moto"),
         "realName": "测试",
         "cardNo": "6222023100025344073"
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 25
0
 def uc_approve_transaction_password_batch(self):
     """
             4.6.1 批量设置资金密码
             :return: 
             """
     server = "uc/approve/transaction/password"
     data = {"jyPassword": "******"}
     sql_result = connect_mysql().connect2mysql(
         "SELECT token FROM member WHERE token LIKE '1111%';")
     result = DKApiBase().mysqlResultFormat(sql_result, ["token"])
     print(result)
     for token in result:
         print({"access-auth-token": token["token"]})
         r = request2DKApi(server, data, {
             "access-auth-token": token["token"]
         }).send()
         print(r)
     print("设置完毕")
Esempio n. 26
0
    def setUp(self):

        # 获取订单明细接口订单号
        self.exchange_order_orderInfo_sql = '''SELECT order_id FROM exchange_order 
        WHERE member_id = '74773' AND completed_time IS NOT NULL ORDER BY completed_time DESC LIMIT 5;'''  # 查询最近成交的订单号
        try:
            # 获取查询到的第一条订单号
            self.exchange_order_orderInfo = DKApiBase().mysqlResultFormat(
                connect_mysql().connect2mysql(
                    self.exchange_order_orderInfo_sql),
                ["order_id"])[0]["order_id"]
        except Exception as e:
            print("获取订单明细查询订单号错误{}".format(e))

        self.announcementID = "8"  # 公告内容接口公告ID
        self.coinId = "5"  # 获取制定币种接口币种ID
        self.coinName = "SLB"  # 资产查询接口币种ID
        self.symbol = "SLB/USDT"  # 币种对
        self.fromdate = "2018-07-23 00:00:00"  # 查询K线数据起始时间
Esempio n. 27
0
 def uc_approve_update_wechat(self):
     """
             4.20修改微信(待调试)
             :return: 
             """
     jyPassword = "******"
     server = "uc/approve/update/wechat"
     data = {
         "wechat":
         "188888888889",
         "jyPassword":
         DKApiBase().getSign(jyPassword + "hello, moto"),
         "realName":
         "测试",
         "qrCodeUrl":
         "http://silktraderpriv.oss-cn-hongkong.aliyuncs.com/2018/08/14/4c12dafb-96c7-4d64-a809-b2f5656ec85e.jpg?Expires=1534238183&OSSAccessKeyId=LTAIWYxtSxH9BJ7T&Signature=wR9M27m9vS5aCBuhrLfDuRrV%2BUY%3D"
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 28
0
 def uc_approve_update_ali(self):
     """
             4.18 修改支付宝(待调试)
             :return: 
             """
     jyPassword = "******"
     server = "uc/approve/update/ali"
     data = {
         "ali":
         "17712345678",
         "jyPassword":
         DKApiBase().getSign(jyPassword + "hello, moto"),
         "realName":
         "测试",
         "qrCodeUrl":
         "http://silktraderpriv.oss-cn-hongkong.aliyuncs.com/2018/08/14/b91b0da1-567a-441a-926f-83fe7f3c129f.jpg?Expires=1534237113&OSSAccessKeyId=LTAIWYxtSxH9BJ7T&Signature=2UEP5GyDbJNaSUQVmk80ryAtQEY%3D"
     }
     r = request2DKApi(server, data).send()
     print(r)
Esempio n. 29
0
 def test_exchange_order_cancel(self):
     """添加and取消委托订单"""
     # 添加
     serverc = "exchange/order/add"
     data = {
         "symbol": self.symbol,
         "price": "1.08",
         "amount": "100",
         "direction": "1",  # 买卖方向,0=BUY(买)/1=SELL(卖)
         "type": "1"  # 交易类型,1=LIMIT_PRICE(限价交易)
     }
     r = request2DKApi(serverc, data).send()
     print(serverc, r)
     # 撤销
     orderId = DKApiBase().str2json(r[2])["data"]["orderId"]
     time.sleep(3)  # 避免取消时订单状态不正确
     serverc = "exchange/order/cancel/" + orderId
     rcancel = request2DKApi(serverc).send()
     print(serverc, rcancel)
     self.assertRegexpMatches(rcancel[2],
                              '"message":"Cancel order success"', "结果断言失败")
Esempio n. 30
0
    def test_otc_advertise_create_update_on_buy_pay_release_off_delete(self):
        """创建买入广告and查询该条广告and修改and上架and卖出交易and确认付款and放币and下架and删除广告"""

        # 创建买入广告
        server = "otc/advertise/create"
        data = {
            "price": self.advertPrice_USDT,
            "advertiseType": "0",  # 0买,1卖
            "coin.id": self.otc_coin_id_USDT,
            "minLimit": "100",
            "maxLimit": "1000",
            "timeLimit": "15",
            "country": "中国",
            "priceType": "0",
            "premiseRate": "",
            "remark": "自动脚本添加",
            "number": "10000",
            "pay[]": "微信",
            "auto": "1",
            "autoword": "自动脚本添加",
            "jyPassword": self.jyPassword
        }
        r_buy = request2DKApi(server, data).send()
        print(r_buy)

        # 查询个人所有广告获得最新创建广告
        server = "otc/advertise/all"
        r_Inquire_buy = request2DKApi(server).send()
        print(r_Inquire_buy)
        advertid_buy = DKApiBase().str2json(
            r_Inquire_buy[2])["data"][0]["id"]  # 从查询接口获取最新发布的这条广告ID

        # 修改广告
        server = "otc/advertise/update"
        data = {
            "id": advertid_buy,
            "advertiseType": "1",  # 0买,1卖
            "price": self.advertPrice_USDT,
            "coin.id": self.otc_coin_id_USDT,
            "minLimit": "100",
            "maxLimit": "1000",
            "timeLimit": "20",
            "country": "中国",
            "priceType": "0",
            "premiseRate": "",
            "remark": "自动脚本添加",
            "number": "100000",
            "pay[]": "支付宝",
            "auto": "1",
            "autoword": "自动脚本添加",
            "jyPassword": self.jyPassword
        }
        r_update_buy = request2DKApi(server, data).send()
        print(r_update_buy)

        # 上架
        server = "otc/advertise/on/shelves"
        data = {"id": advertid_buy}
        r_on_buy = request2DKApi(server, data).send()
        print(r_on_buy)

        # 用户卖出
        time.sleep(3)
        server = "otc/order/sell"
        data = {
            "id": advertid_buy,  # 广告id
            "coinId": self.otc_coin_id_USDT,  # 币种id,otc_coin表ID
            "price": self.advertPrice_USDT,  # 当前价格
            "money": self.advertPrice_USDT * self.amount,  # 金额
            "amount": self.amount,  # 数量
            "remark": "自动脚本测试卖币",  # 要求、备注,非必传
            "mode": ""  # 计算方式,金额/价格=数量为0,数量*价格=金额为1,非必传,默认为0
        }
        r_sale_buy = request2DKApi(server, data, self.header).send()
        print(r_sale_buy)
        orderSn_buy = DKApiBase().str2json(
            r_sale_buy[2])["data"]  # 下单结果获取交易订单号
        if orderSn_buy is None:
            self.assertRegexpMatches(r_sale_buy[2], '"message" : "创建订单成功"',
                                     "创建订单失败")

        # 买家确认付款
        time.sleep(2)
        server = "otc/order/pay"
        data = {"orderSn": orderSn_buy}
        r_pay_buy = request2DKApi(server, data).send()
        print(r_pay_buy)

        # 卖家放币
        time.sleep(2)  # 等待2s避免订单状态更改不及时
        server = "otc/order/release"
        data = {"orderSn": orderSn_buy, "jyPassword": self.jyPassword}
        r_rel_buy = request2DKApi(server, data, self.header).send()
        print(r_rel_buy)

        # 下架
        server = "otc/advertise/off/shelves"
        data = {"id": advertid_buy}
        r_off = request2DKApi(server, data).send()
        print(r_off)
        # 删除广告
        server = "otc/advertise/delete"
        data = {"id": advertid_buy}  # 广告ID
        r_del = request2DKApi(server, data).send()
        print(r_del)
        self.assertRegexpMatches(r_del[2], '"message" : "删除成功"', "结果断言失败")