コード例 #1
0
    def testLogin(self):
        """
        test body
        :return:
        """
        # set url
        self.url = url.users_loginWithPhoneAndPassword
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        #set headers
        configHttp.set_headers()
        print("第二步:设置headers")

        # set data
        data = json.dumps({
            "mobilePhoneNumber": self.mobilePhoneNumber,
            "password": self.password,
            "reaCode": self.areaCode
        })
        configHttp.set_data(data)
        print("第三步:设置发送请求的参数")

        # test interface
        self.response = configHttp.post()
        print("第四步:发送请求\n\t\t请求方法:")

        self.checkResult()
        print("第五步:检查结果")
コード例 #2
0
    def testSmsCode(self):
        """
        test body
        :return:
        """
        # set url
        self.url = url.users_getSmsCode

        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        configHttp.set_headers()
        print("第二步:设置headers")

        # set date
        data = json.dumps({
            "mobilePhoneNumber": self.mobilePhoneNumber,
            "action": self.action,
            "reaCode": self.areaCode
        })
        configHttp.set_data(data)
        print("第三步:设置发送请求的参数")

        # test interface
        self.response = configHttp.post()
        print("第四步:发送请求\t\t请求方法:" + self.method)

        self.checkResult()
        print("第五步:检查结果")
コード例 #3
0
    def testRedBag(self):
        '''
        发红包
        :return:
        '''
        self.url = common.get_url_from_xml('redBag')

        # set url
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # set data
        data = {
            'amount': self.amount,
            'coin_type': self.coin_type,
            'count': self.count,
            'info': self.info,
            'need_sign': self.need_sign,
            'type': self.type
        }
        configHttp.set_data(data)

        # test interface
        self.return_json = configHttp.request_json_post()
コード例 #4
0
    def testCase(self):
        """
        test body
        :return:
        """
        # set url
        self.url = url.users_profile
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # set params
        params = {"username": self.username}
        configHttp.set_params(params)

        # set date
        data = json.dumps({
            "mobilePhoneNumber": self.mobilePhoneNumber,
            "password": self.password,
            "reaCode": self.areaCode
        })
        configHttp.set_data(data)

        # test interface
        self.response = configHttp.get()

        # check result
        self.checkResult()
コード例 #5
0
    def testSendVerifyCode(self):
        """
        test body
        :return:
        """
        print("开始执行用例====================>>>>")
        # get url
        self.url = common.get_url_from_xml('sendVerifyCode')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # get visitor token
        if self.token == '1':
            token = localReadConfig.get_headers("token_v")
        elif self.token == '0':
            token = None

        # set headers
        header = {"Content-Type": "application/json"}
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        # set params
        body = {"mobile": self.mobile}
        configHttp.set_data(body)
        print("第三步:设置发送请求的参数", body)

        # test interface
        print("第四步:发送请求请求方法:")
        self.return_json = configHttp.postWithJson()

        # check result
        print("第五步:检查结果")
        self.checkResult()
コード例 #6
0
    def testLogout(self):
        """
        test body
        :return:
        """
        print("开始执行用例====================>>>>")
        # get url
        self.url = common.get_url_from_xml('logout')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # get visitor token
        if self.token == '1':
            token = self.user_token
        elif self.token == '0':
            token = None

        # set headers
        header = {"authorization": token, "Content-Type": "application/json"}
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        # set params
        body = {"unbind": self.unbind}
        configHttp.set_data(body)
        print("第三步:设置发送请求的参数", body)

        # test interface
        print("第四步:发送请求请求方法:")
        self.return_json = configHttp.postWithJson()

        # check result
        print("第五步:检查结果")
        self.checkResult()
コード例 #7
0
def get_profile(user_token):
    url = common.get_url_from_xml('getProfile')
    configHttp.set_url(url)
    header = {'authorization': user_token}
    configHttp.set_headers(header)
    return_json = configHttp.get()
    return return_json.json()
コード例 #8
0
    def testGetProfile(self):
        """
        test body
        :return:
        """
        print("开始执行用例====================>>>>")
        # get url
        self.url = common.get_url_from_xml('getProfile')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # get visitor token
        if self.token == '1':
            token = writeConfig.read_user_token('user_token')
            print("用户token为:", token)
        elif self.token == '0':
            token = None

        # set headers
        header = {'authorization': token}
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        # set params
        body = {}
        configHttp.set_data(body)
        print("第三步:设置发送请求的参数", body)

        # test interface
        print("第四步:发送请求请求方法:")
        self.return_json = configHttp.get()

        # check result
        print("第五步:检查结果")
        self.checkResult()
コード例 #9
0
    def testGetCity(self):
        """
        test body
        :return:
        """
        print("开始执行第一个用例==============>>>>>>>>>")
        # get url
        self.url = common.get_url_from_xml('getCityList')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # get visitor token
        if self.token == '1':
            token = localReadConfig.get_headers("token_v")
        elif self.token == '0':
            token = None

        # set headers
        header = {"authorization": str(token)}
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        # set params
        params = {"type": self.type}
        configHttp.set_params(params)
        print("第二步:设置发送请求的参数", self.type)

        # test interface
        print("第三步:发送请求请求方法:")
        self.return_json = configHttp.get()

        # check result
        print("第四步:检查结果")
        self.checkResult()
コード例 #10
0
    def testpayAddress(self):
        '''
        地址付款
        :return:
        '''
        self.url = common.get_url_from_xml('payAddress')

        # set url
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # set data
        data = {'address':self.address,
                'amount':self.amount,
                'coin_type':self.coin_type,
                'info':self.info,
                'need_sign':self.need_sign}
        configHttp.set_data(data)

        # test interface
        self.return_json = configHttp.request_json_post()

        self.checkResult()
コード例 #11
0
def send_verify_code(mobile):
    url = common.get_url_from_xml('sendVerifyCode')
    configHttp.set_url(url)
    header = {"Content-Type": "application/json"}
    configHttp.set_headers(header)
    body = {"mobile": mobile}
    configHttp.set_data(body)
    return_json = configHttp.postWithJson()
    return return_json.json()
コード例 #12
0
def logout(token):
    url = common.get_url_from_xml('logout')
    configHttp.set_url(url)
    header = {"authorization": token, "Content-Type": "application/json"}
    configHttp.set_headers(header)
    body = {"unbind": 'true'}
    configHttp.set_data(body)
    return_json = configHttp.postWithJson()
    return return_json
コード例 #13
0
def check_verify_code(mobile, mobile_code):
    url = common.get_url_from_xml('checkVerifyCode')
    configHttp.set_url(url)
    header = {"Content-Type": "application/json"}
    configHttp.set_headers(header)
    body = {"mobile": mobile, "code": mobile_code}
    configHttp.set_data(body)
    return_json = configHttp.postWithJson()
    return return_json.json()['data']['token']
コード例 #14
0
    def testrealface(self):
        """
        test body
        :return:
        """
        # set url
        # self.url = "/api/front/real-name-test"
        self.url = common.get_url_from_xml('realface')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)
        # get visitor token

        if self.token == '0':
            token = str(self.login_token)

        else:
            token = None
        # print(token)
        token1 = "Bearer " + str(token)
        # print(token1)
        header = {
            "Content-Type": "application/json",
            "Authorization": str(token1)
        }
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        self.photo_id = businessCommon.upload(1)
        print("#######" + self.photo_id)
        data = {
            "realname": self.realname,
            "idcard": self.idcard,
            "photoId": self.photo_id
        }
        configHttp.set_data(data)
        print("第三步:设置发送请求的参数")

        # test interface
        self.return_json = configHttp.postWithJson()
        print(self.return_json)  # 返回<Response [200]>
        print(self.return_json.request)  # <PreparedRequest [POST]>
        method = str(self.return_json.request
                     )[int(str(self.return_json.request).find('[')) +
                       1:int(str(self.return_json.request).find(']'))]
        print("第四步:发送请求\n\t\t请求方法:" + method)

        # check result
        self.checkResult()
        print("第五步:检查结果")
コード例 #15
0
    def testrealname(self):
        """
        test body
        :return:
        """
        # set url
        # self.url = "/api/front/real-name-test"
        self.url = common.get_url_from_xml('realname')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # get visitor token

        if self.token == '1':
            token = None

        else:
            token = localReadConfig.get_headers("Authorization")
        # header = {'Authorization': "Bearer " + str(token)}
        # configHttp.set_headers(header)
        token1 = "Bearer" + str(token)
        print("当前token**:" + token1)
        # set headers

        header = {
            "Content-Type": "application/json",
            "Authorization": str(token1)
        }
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        # set params
        data = {"realname": self.realname, "idcard": self.idcard}
        configHttp.set_data(data)
        print("第三步:设置发送请求的参数")

        # test interface
        self.return_json = configHttp.postWithJson()
        print(self.return_json)  # 返回<Response [200]>
        print(self.return_json.request)  # <PreparedRequest [POST]>
        method = str(self.return_json.request
                     )[int(str(self.return_json.request).find('[')) +
                       1:int(str(self.return_json.request).find(']'))]
        print("第四步:发送请求\n\t\t请求方法:" + method)

        # check result
        self.checkResult()
        print("第五步:检查结果")
コード例 #16
0
    def testBalance(self):
        '''
        查询余额
        :return:
        '''
        self.url = common.get_url_from_xml('balance')

        # set url
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # test interface
        self.return_json = configHttp.request_get()

        self.checkResult()
コード例 #17
0
    def testInfo_chain(self):
        # set url
        self.url = common.get_url_from_xml('info_chain')
        url = configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers(self.headers)
        print(self.headers)

        # test interface
        try:
            self.return_json = configHttp.requests_by_method(self.method)
        except Exception as Ex:
            self.logger.exception(Ex)
            return

        common.checkResult(url, self.return_json, self.code)
コード例 #18
0
    def testuserInfo(self):
        '''
        用户信息
        :return:
        '''
        self.url = common.get_url_from_xml('userInfo')

        # set url
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # test interface
        self.return_json = configHttp.request_get()

        self.checkResult()
コード例 #19
0
    def testGetHostedAccount(self):

        self.url = common.get_url_from_xml('feeQuote')
        # set url
        url = configHttp.set_url(self.url)
        print(url)

        # set headers
        configHttp.set_headers(self.headers)
        print(self.headers)

        # test interface
        try:
            self.return_json = configHttp.requests_by_method(self.method)
            print(self.return_json.text)
        except Exception as Ex:
            self.logger.exception(Ex)
            return
コード例 #20
0
    def testUpdateProfile(self):
        """
        test body
        :return:
        """
        print("开始执行用例====================>>>>")
        # get url
        self.url = common.get_url_from_xml('updateProfile')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # get visitor token
        if self.token == '1':
            token = writeConfig.read_user_token('user_token')
            print("用户token为:", token)
        elif self.token == '0':
            token = None

        # set headers
        header = {'authorization': token}
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        # set params
        random_str = ''.join(random.sample(string.ascii_letters + string.digits, 4))
        full_name = self.name+random_str
        if self.name != "" and self.gender == "" and self.birthday == "":
            body = {"name": full_name}
        elif self.name == "" and self.gender != "" and self.birthday == "":
            body = {"gender": self.gender}
        elif self.name == "" and self.gender == "" and self.birthday != "":
            body = {"birthday": self.birthday}
        elif self.name != "" and self.gender != "" and self.birthday != "":
            body = {"name": full_name, "gender": self.gender, "birthday": self.birthday}
        configHttp.set_data(body)
        print("第三步:设置发送请求的参数", body)

        # test interface
        print("第四步:发送请求请求方法:")
        self.return_json = configHttp.putWithJson()

        # check result
        print("第五步:检查结果")
        self.checkResult()
コード例 #21
0
    def testGetDisease(self):
        """
        test body
        :return:
        """
        print("开始执行第一个用例==============>>>>>>>>>")
        # get url
        self.url = common.get_url_from_xml('getDiseasesList')
        configHttp.set_url(self.url)
        print("第一步:设置url  " + self.url)

        # get visitor token
        if self.token == '1':
            token = localReadConfig.get_headers("token_v")
        elif self.token == '0':
            token = None

        # set headers
        header = {"authorization": str(token)}
        configHttp.set_headers(header)
        print("第二步:设置header(token等)")

        # set params
        params = {
            "isCommon": self.isCommon,
            "name": self.name,
            "parentCategoryId": self.parentCategoryId,
            "categoryId": self.categoryId,
            "relatedDoctor": self.relatedDoctor,
            "page": self.page,
            "pageSize": self.pageSize
        }
        configHttp.set_params(params)
        print("第二步:设置发送请求的参数", params)

        # test interface
        print("第三步:发送请求请求方法:")
        self.return_json = configHttp.get()

        # check result
        print("第四步:检查结果")
        self.checkResult()
コード例 #22
0
    def testCount(self):

        self.url = common.get_url_from_xml('count')
        # set url
        url = configHttp.set_url(self.url)
        print(url)

        # set headers
        self.header['token'] = configHttp.get_openapi_token()
        configHttp.set_headers(self.header)
        print(self.header)

        # test interface
        try:
            self.return_json = configHttp.requests_by_method(self.method)
        except Exception as Ex:
            self.logger.exception(Ex)
            return

        common.checkResult(url, self.return_json, self.code)
コード例 #23
0
    def testBlockHeader(self):
        # set url
        self.url = common.get_url_from_xml('blockheader')
        url = configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers(self.headers)
        print(self.headers)

        # set params
        configHttp.set_data(self.data)
        print(self.data)

        # test interface
        try:
            self.return_json = configHttp.requests_by_method(self.method)
        except Exception as Ex:
            self.logger.exception(Ex)
            return

        common.checkResult(url, self.return_json, self.code)
コード例 #24
0
    def testFlow(self):
        self.url = common.get_url_from_xml('flow')

        # set url
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # set params
        params = {
            'coin_type': self.coin_type,
            'page': self.page,
            'page_size': self.page_size
        }
        configHttp.set_params(params)

        # test interface
        self.return_json = configHttp.request_get()

        self.checkResult()
コード例 #25
0
    def testUsersProfile(self):
        """
        test body
        :return:
        """
        # set url
        self.url = url.users_profile
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # set params
        params = {"username": self.username}
        configHttp.set_params(params)

        # test interface
        self.response = configHttp.get()

        # check result
        self.checkResult()
コード例 #26
0
    def testDetail(self):
        '''
        查询某笔交易详情
        :return:
        '''
        self.url = common.get_url_from_xml('detail')

        # set url
        configHttp.set_url(self.url)

        # set headers
        configHttp.set_headers()

        # set params
        params = {'tx_id':self.tx_id,
                 'coin_type':self.coin_type}
        configHttp.set_params(params)

        # test interface
        self.return_json = configHttp.request_get()

        self.checkResult()
コード例 #27
0
    def testTopicsGetDetail(self):
        """
        test body
        :return:
        """
        # set url
        self.url = url.topics_getDetail
        configHttp.set_url(self.url)

        # set headers
        getHeaders.login_refresh_token()
        configHttp.set_headers()

        # set params
        params = {"id": self.topics_id, "ref": self.ref}
        configHttp.set_params(params)

        # test interface
        self.response = configHttp.get()

        # check result
        self.checkResult()
コード例 #28
0
    def testGetHostedAccount(self):

        self.url = common.get_url_from_xml('get_hosted_account_balance')
        # set url
        url = configHttp.set_url(self.url)
        print(url)

        # set headers

        configHttp.set_headers(self.headers)

        # set data
        configHttp.set_data(self.data)

        # test interface
        try:
            self.return_json = configHttp.requests_by_method(self.method)
        except Exception as Ex:
            self.logger.exception(Ex)
            return

        common.checkResult(url, self.return_json, self.code)
コード例 #29
0
    def testTopicsGetDetail(self):
        """
        test body
        :return:
        """
        # set url
        self.url = url.topics_listInvolvedUsers
        configHttp.set_url(self.url)

        # set headers
        getHeaders.login_refresh_token()
        configHttp.set_headers()

        # set date
        data = json.dumps({"topicId": self.topics_id, "limit": self.limit})
        configHttp.set_data(data)

        # test interface
        self.response = configHttp.post()

        # check result
        self.checkResult()
コード例 #30
0
    def testTxRawtx(self):

        self.url = common.get_url_from_xml('tx_Rawtx')
        # set url
        url = configHttp.set_url(self.url)
        print(url)

        # set headers
        headers = configHttp.set_headers(self.headers)
        print(headers)

        # test interface
        try:
            self.return_json = configHttp.requests_by_method(self.method)
        except Exception as Ex:
            self.logger.exception(Ex)
            return

        common.checkResult(url, self.return_json, self.code)