Exemplo n.º 1
0
    def test_api_all(self):
        '''测试接口'''
        datas = ExcelReader(self.excel_path).data
        for d in datas:
            if d['run'].lower() == 'yes':
                with self.subTest(data=d['describe']):
                    url = self.c.API_URL + d['api']
                    method = d['method']
                    data = d['data']
                    sql_value = d['sql_value']
                    expect_data = str(d['expect_data'])
                    pd_id = d['pd_id']
                    # 判断excel上面的data不为空时执行获取datas,否则执行不传data的get方法
                    if data != '':
                        datas = self.excel_data.excel_data()[data]
                        if method == 'post':
                            res = HTTPClient(url=url, method=method).send(data=datas).json()
                        else:
                            res = HTTPClient(url=url, method=method).send(params=datas).json()
                    else:
                        res = HTTPClient(url=url, method=method).send().json()

                    logger.debug('响应code字段:%s' % res['code'])
                    # 判断响应json数据中的code字段
                    self.e.assertHTTPCode(res)
                    #判断sql结果和预期结果
                    if sql_value:
                        if pd_id:
                            expect_data = self.excel_data.get_coin()   #替换预期结果为账号最新余额coin字段
                        sql = self.reader_sql.get_new_date_all_activity_id(sql_value)
                        self.e.assertMysqldata(sql,expect_data)
Exemplo n.º 2
0
 def getJson(self, GTId):
     self.params['GTId'] = GTId
     client = HTTPClient(url=self.url, method='POST', headers=self.headers)
     res = client.send(params=self.params)
     j = JMESPathExtractor()
     VedioList = j.extract(query='VedioList[]', body=res.text)
     PicList = j.extract(query='PicList[]', body=res.text)
     return PicList, VedioList
Exemplo n.º 3
0
 def test_prm_http(self):
     URLS = ExcelReader(self.excel).data
     for u in URLS:
         with self.subTest(url=u):
             self.sub_setUp()
             self.client = HTTPClient(url=u['url'], method='GET')
             res = self.client.send()
             logger.debug(res.text)
             self.assertEqual(res.json()['status'], 'UP')
Exemplo n.º 4
0
 def get_token(self):
     '''获取登录接口api_token字典'''
     url = self.API_URL + 'pub/login'
     data = {'username': self.c.username, 'password': self.c.password}
     try:
         res = HTTPClient(url=url, method='post').send(data=data)
     except Exception as e:
         raise GETTOKENException('获取登录响应失败: %s' % str(e))
     token = res.json()['data']
     data_dict = {'api_token': token}
     return data_dict
Exemplo n.º 5
0
 def test_Xjx_Dr_borrowMoney1(self):
     '''
     大额借款前置方法(请求江西银行存管查询接口)
     :return:
     '''
     before_url = self.url
     # 在测试参数前后追加双引号
     str_test_data = "%s" % self.test_data
     client = HTTPClient(url=before_url,
                         method='POST',
                         headers=self.test_headers)
     res = client.send(data=str_test_data, params=self.data)
     logger.info('123client返回的参数:{0}'.format(res.text))
     # 获取traceNo参数
     self.traceNo = self.j.extract(query='data.traceNo', body=res.text)
     self.borrowMoney_test_data['traceNo'] = self.traceNo
     # 获取userBankCardId参数
     select_orderid = "select id from asset_borrow_order where user_id = '768093098' ORDER BY id DESC LIMIT 1"
     logger.info('查询数据库数据的sql为:{0}'.format(select_orderid))
     db_order_id = self.get_dbdata.fetch_one(select_orderid)
     self.userBankCardId = self.j.extract(query='data.traceNo',
                                          body=res.text)
     # 断言
     # 获取borrowMoney.json文件中的assertlist数据
     self.assertlist = JsonConfig(
         path='wholesale', jsonpath='borrowMoney.json').get_jsondata(
             element='before_borrowMoney_assertlist')
     logger.info('assertlist数据为:{0}'.format(self.assertlist))
     # 断言rsq_code
     rsq_code = self.j.extract(query='code', body=res.text)
     self.assertEqual(rsq_code,
                      self.j.addextract(query='code', body=self.assertlist))
     # 断言rsq_message
     rsq_message = self.j.extract(query='message', body=res.text)
     self.assertEqual(
         rsq_message,
         self.j.addextract(query='message', body=self.assertlist))
     # 断言rsq_orderAmount
     rsq_orderAmount = self.j.extract(query='data.orderAmount',
                                      body=res.text)
     self.assertEqual(
         rsq_orderAmount,
         self.j.addextract(query='orderAmount', body=self.assertlist))
     # 断言rsq_bankName
     rsq_bankName = self.j.extract(query='data.bankName', body=res.text)
     self.assertEqual(
         rsq_bankName,
         self.j.addextract(query='bankName', body=self.assertlist))
     # 断言rsq_cardNoLastFour
     rsq_cardNoLastFour = self.j.extract(query='data.cardNoLastFour',
                                         body=res.text)
     self.assertEqual(
         rsq_cardNoLastFour,
         self.j.addextract(query='cardNoLastFour', body=self.assertlist))
Exemplo n.º 6
0
class TestBaiDuHTTP(unittest.TestCase):
    URL = Config().get('URL')

    def setUp(self):
        self.client = HTTPClient(url=self.URL, method='GET')

    def test_baidu_http(self):
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [200])
        self.assertIn('百度一下,你就知道', res.text)

    def tearDown(self):
        self.client.close()
Exemplo n.º 7
0
 def getTeams(self):
     client = HTTPClient(url=self.url, method='GET')
     res = client.send(params=self.params)
     # print(res.text)
     soup = BeautifulSoup(res.text, "html.parser")
     team_divs = soup.select(".Team")
     # <div class="Team active" gtid="a614ae1c-597a-431d-8134-de681cdabca3">队伍3</div>
     teams = []
     for team_div in team_divs:
         # print(team_div.get_text(),team_div.get('gtid'))
         teams.append({
             'name': team_div.get_text(),
             'id': team_div.get('gtid')
         })
     return teams
Exemplo n.º 8
0
    def after(self):
        # tearDown method
        if self.teardown:
            for step in self.teardown:
                step_url = step.get('url')
                if not step_url:
                    continue
                step_method = step.get('method', 'GET')
                step_headers = step.get('headers')
                step_params = step.get('params')
                step_data = step.get('data')
                # debug
                logger.debug('teardown url: %s' % step_url)
                logger.debug('teardown method: %s' % step_method)
                if step_headers:
                    logger.debug('teardown headers: %s' % step_headers)
                if step_params:
                    logger.debug('teardown params: %s' % step_params)
                if step_data:
                    logger.debug('teardown data: %s' % step_data)

                HTTPClient(url=step_url,
                           method=step_method,
                           headers=step_headers).send(params=step_params,
                                                      data=step_data)
Exemplo n.º 9
0
    def before(self):
        # setUp method
        if self.setup:
            for step in self.setup:
                step_url = step.get('url')
                if not step_url:
                    continue
                step_method = step.get('method', 'GET')
                step_headers = step.get('headers')
                step_params = step.get('params')
                step_data = step.get('data')
                # debug
                logger.debug('setup url: %s' % step_url)
                logger.debug('setup method: %s' % step_method)
                if step_headers:
                    logger.debug('setup headers: %s' % step_headers)
                if step_params:
                    logger.debug('setup params: %s' % step_params)
                if step_data:
                    logger.debug('setup data: %s' % step_data)

                HTTPClient(url=step_url,
                           method=step_method,
                           headers=step_headers).send(params=step_params,
                                                      data=step_data)
Exemplo n.º 10
0
class Test_Xjx_login(unittest.TestCase):
    URL = Config().get('URL')
    logger.info('请求的URL为:{0}'.format(URL))
    LOGIN_URL = Config().get('login_url')

    LOGIN = URL + LOGIN_URL

    def test_Xjx_login(self):
        self.j = JMESPathExtractor()
        self.jsondata = JsonConfig()
        # 获取json配置文件数据
        jsondata = JsonConfig().get_jsondata()
        logger.info('开始执行app登录接口,caseName:test_Xjx_Login')
        self.client = HTTPClient(url=self.LOGIN, method='POST')
        logger.info('请求的api路径为:{0}'.format(self.LOGIN_URL))
        logger.info('拼接后的请求路径为:{0}'.format(self.LOGIN))
        res = self.client.send(data=jsondata)
        logger.info('接口入参为:{0}'.format(jsondata))
        self.assertIn('登录成功', res.text)
        self.sessionid = self.j.extract(query='data.item.sessionid',
                                        body=res.text)
        jsondata['sessionid'] = self.sessionid
        logger.info('该用户的sessionid为:{0}'.format(self.sessionid))
        # print('该用户的sessionid为:{0}'.format(self.sessionid))
        return self.sessionid
Exemplo n.º 11
0
 def test_xjx_http_index1(self):
     logger.info('开始执行app首页接口,caseName:test_xjx_http_index1')
     self.client = HTTPClient(url=self.INDEX, method='GET')
     logger.info('请求的api路径为:{0}'.format(self.INDEX_URL))
     logger.info('拼接后的请求路径为:{0}'.format(self.INDEX))
     res = self.client.send(params=self.data)
     logger.info('返回的参数为:{0}'.format(res.text))
     logger.info('接口入参为:query--{0}'.format(self.data))
     self.assertIn('访问首页成功', res.text)
     # data.item.loginStatus的值为登录标识,1为已登录;0为未登录
     login_status = self.j.extract(query='data.item.loginStatus',
                                   body=res.text)
     logger.info('login_status的值为:{0}'.format(login_status))
     # print(login_status)
     # 判断login_status的值是否是1
     self.assertEqual(login_status, '1')
     return self.data
    def test_xjx_borrowMoney1(self):
        BorrowMoney = self.URL + self.BorrowMoney_URL
        logger.info('开始执行app借款接口,caseName:test_xjx_borrowMoney1')
        self.client = HTTPClient(url=BorrowMoney, method='POST')
        logger.info('请求的api路径为:{0}'.format(self.BorrowMoney_URL))
        logger.info('拼接后的请求路径为:{0}'.format(BorrowMoney))

        res = self.client.send(data=self.jsondata)
        # res = requests.post(url=BorrowMoney, data=self.jsondata)
        logger.info('返回的参数为:{0}'.format(res.text))
        logger.info('接口入参为:query--{0}'.format(self.jsondata))
        self.assertIn('中国农业银行', res.text)
        self.assertIn('成功', res.text)
        # data.item.card_no_lastFour的值为该测试用户的银行卡最后四位
        card_no_lastFour = self.j.extract(query='data.item.card_no_lastFour',
                                          body=res.text)
        # # 判断card_no_lastFour的值是否一致
        self.assertEqual(card_no_lastFour, '0002')
Exemplo n.º 13
0
 def test_calcPrice(self):
     test_calcPrice_url = self.URL + 'calcPrice.json'
     '''plus100万有社保'''
     for i in range(1, 13):
         list = ExcelReader(
             'C:/Users/Administrator/Desktop/Test_framework-master/data/interface.xlsx',
             sheet='e生保plus',
             title_line=False).data
         birtday = str(Date().birthday(int(list[i][1])))
         param = 'accessToken=CSddCECfcCncynT09LOII3g7352Ke36U&appVersionName=3.9.3&birthday=641660400&channel=App_Store&deviceId=24FD57FF-5EB7-4E89-8AAF-566B1A421F78&deviceType=iPhone&insuranceId=32&insuranceScheme={  "insPlan" : "2000000",  "safePeriod" : "5",  "insurantBirthday" : "28天-60周岁"}&insurants=[{"insurantIdType":1,"id":"6916140","insurantName":"刘思思","insurantNo":"4106**********9203","birthday":' + birtday + ',"hasSocialSecurity":1,"insurantIsSelf":"1","relation":"1","sex":1,"insurantPhone":"18601122321","insurantPermanentResidence":"2"}]&iphoneDesc=Simulator&iphoneType=x86_64&language=zh&netType=1&period=5&platform=1&resolution={414, 896}&screenSize=11&sex=1&shareLimit=1&supportCase=770&timestamp=1559886348&userId=6916140&vendorId=8A58C566-68D1-494C-9899-32BF781BCC0B&version=1.0.1'
         self.client = HTTPClient(url=test_calcPrice_url, method='GET')
         res = self.client.send(params=param)
         price = str(list[i][2])
         assertStr(res.text, 'price":', ',"limit', price)
         logger.debug(res.text)
     '''plus100万无社保'''
     for i in range(14, 26):
         list = ExcelReader(
             'C:/Users/Administrator/Desktop/Test_framework-master/data/interface.xlsx',
             sheet='e生保plus',
             title_line=False).data
         birtday = str(Date().birthday(int(list[i][1])))
         param = 'accessToken=CSddCECfcCncynT09LOII3g7352Ke36U&appVersionName=3.9.3&birthday=641660400&channel=App_Store&deviceId=24FD57FF-5EB7-4E89-8AAF-566B1A421F78&deviceType=iPhone&insuranceId=32&insuranceScheme={  "insPlan" : "2000000",  "safePeriod" : "5",  "insurantBirthday" : "28天-60周岁"}&insurants=[{"insurantIdType":1,"id":"6916140","insurantName":"刘思思","insurantNo":"4106**********9203","birthday":' + birtday + ',"hasSocialSecurity":2,"insurantIsSelf":"1","relation":"1","sex":1,"insurantPhone":"18601122321","insurantPermanentResidence":"2"}]&iphoneDesc=Simulator&iphoneType=x86_64&language=zh&netType=1&period=5&platform=1&resolution={414, 896}&screenSize=11&sex=1&shareLimit=1&supportCase=770&timestamp=1559886348&userId=6916140&vendorId=8A58C566-68D1-494C-9899-32BF781BCC0B&version=1.0.1'
         self.client = HTTPClient(url=test_calcPrice_url, method='GET')
         res = self.client.send(params=param)
         price = str(list[i][2])
         assertStr(res.text, 'price":', ',"limit', price)
         logger.debug(res.text)
     '''plus300万有社保'''
     for i in range(27, 39):
         list = ExcelReader(
             'C:/Users/Administrator/Desktop/Test_framework-master/data/interface.xlsx',
             sheet='e生保plus',
             title_line=False).data
         birtday = str(Date().birthday(int(list[i][1])))
         param = 'accessToken=CSddCECfcCncynT09LOII3g7352Ke36U&appVersionName=3.9.3&birthday=641660400&channel=App_Store&deviceId=24FD57FF-5EB7-4E89-8AAF-566B1A421F78&deviceType=iPhone&insuranceId=32&insuranceScheme={  "insPlan" : "6000000",  "safePeriod" : "5",  "insurantBirthday" : "28天-60周岁"}&insurants=[{"insurantIdType":1,"id":"6916140","insurantName":"刘思思","insurantNo":"4106**********9203","birthday":' + birtday + ',"hasSocialSecurity":1,"insurantIsSelf":"1","relation":"1","sex":1,"insurantPhone":"18601122321","insurantPermanentResidence":"2"}]&iphoneDesc=Simulator&iphoneType=x86_64&language=zh&netType=1&period=5&platform=1&resolution={414, 896}&screenSize=11&sex=1&shareLimit=1&supportCase=771&timestamp=1559886348&userId=6916140&vendorId=8A58C566-68D1-494C-9899-32BF781BCC0B&version=1.0.1'
         self.client = HTTPClient(url=test_calcPrice_url, method='GET')
         res = self.client.send(params=param)
         price = str(list[i][2])
         assertStr(res.text, 'price":', ',"limit', price)
         logger.debug(res.text)
     '''plus300万无社保'''
     for i in range(40, 52):
         list = ExcelReader(
             'C:/Users/Administrator/Desktop/Test_framework-master/data/interface.xlsx',
             sheet='e生保plus',
             title_line=False).data
         birtday = str(Date().birthday(int(list[i][1])))
         param = 'accessToken=CSddCECfcCncynT09LOII3g7352Ke36U&appVersionName=3.9.3&birthday=641660400&channel=App_Store&deviceId=24FD57FF-5EB7-4E89-8AAF-566B1A421F78&deviceType=iPhone&insuranceId=32&insuranceScheme={  "insPlan" : "6000000",  "safePeriod" : "5",  "insurantBirthday" : "28天-60周岁"}&insurants=[{"insurantIdType":1,"id":"6916140","insurantName":"刘思思","insurantNo":"4106**********9203","birthday":' + birtday + ',"hasSocialSecurity":2,"insurantIsSelf":"1","relation":"1","sex":1,"insurantPhone":"18601122321","insurantPermanentResidence":"2"}]&iphoneDesc=Simulator&iphoneType=x86_64&language=zh&netType=1&period=5&platform=1&resolution={414, 896}&screenSize=11&sex=1&shareLimit=1&supportCase=771&timestamp=1559886348&userId=6916140&vendorId=8A58C566-68D1-494C-9899-32BF781BCC0B&version=1.0.1'
         self.client = HTTPClient(url=test_calcPrice_url, method='GET')
         res = self.client.send(params=param)
         price = str(list[i][2])
         assertStr(res.text, 'price":', ',"limit', price)
         logger.debug(res.text)
Exemplo n.º 14
0
 def get_activity_gold_id(self):
     '''体验金id'''
     url = self.API_URL + 'activity/activity_gold_id'
     res = HTTPClient(url=url, method='get').send(params=self.token).json()
     try:
         dict_id = {'id': res['data']['id']}
         datas = dict(self.token, **dict_id)  #合并两个字典为一个字典
         return datas
     except Exception:
         pass
Exemplo n.º 15
0
 def get_activity_get_status_sign(self):
     '''签到活动id'''
     url = self.API_URL + 'activity/get_status_sign'
     res = HTTPClient(url=url, method='get').send(params=self.token).json()
     try:
         Activity_id = {'id': res['data'][0]['Activity_id']}
         datas = dict(self.token, **Activity_id)
         return datas
     except Exception:
         pass
Exemplo n.º 16
0
    def test_Xjx_Dr_borrowMoney2(self):
        '''
        大额借款方法
        :return:
        '''
        borrowMoney_url = Config().get('borrowMoney_url')
        url = self.base_url + borrowMoney_url
        logger.info('大额借款的接口地址为:{0}'.format(url))

        client = HTTPClient(url=url, method='POST', headers=self.test_headers)
        #set相关参数到测试参数中
        self.borrowMoney_test_data[
            'userBankCardId'] = self.one_db_userBankCardId_id
        # 在测试参数前后追加双引号
        # test_data = self.borrowMoney_test_data.encode("utf-8")
        str_test_data = "%s" % self.borrowMoney_test_data

        logger.info('321参数:{0}'.format(str_test_data))
        res = client.send(data=str_test_data, params=self.data)
        logger.info('123456client返回的参数:{0}'.format(res.text))
Exemplo n.º 17
0
class TestBaiDuHTTP(unittest.TestCase):
    URL = Config().get('URL')

    def setUp(self):
        self.client = HTTPClient(url=self.URL, method='GET')

    def test_baidu_http(self):
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [400])
        self.assertIn('百度一下,你就知道', res.text)
Exemplo n.º 18
0
class TestBingHTTP(unittest.TestCase):
    URL = Config().get('URL')

    def setUp(self):
        self.client = HTTPClient(url=self.URL, method='GET')

    def test_bing_http(self):
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [400])
        self.assertIn('微软Bing', res.text)
Exemplo n.º 19
0
class TestThirdPartyHTTP(unittest.TestCase):
    URL = Config().get('URL')

    def setUp(self):
        self.client = HTTPClient(url=self.URL, method='GET')

    def test_thirdparty_http(self):
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [400])
        self.assertIn(u'ThirdParty', res.text)
Exemplo n.º 20
0
class TestloginHTTP(unittest.TestCase):
    LoginURL = Config().get('LoginURL')

    def setUp(self):
        self.client = HTTPClient(url=self.LoginURL, method='GET')

    def test_login_http(self):
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [400])
        self.assertIn('嗯哼嗯哼蹦擦擦', res.text)
class TestBaiDuHTTP(unittest.TestCase):
    URL = Config().get('URL')

    def setUp(self):
        self.client = HTTPClient(url=self.URL, method='GET')

    def test_baidu_http(self):
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [400])# 实际返回的是200,不再传入的400中,所以断言为false,后面代码也不会执行了。
        self.assertIn('百度一下,你就知道', res.text) # 不执行了
Exemplo n.º 22
0
    def test_login_01(self):
        '''测试接口'''
        datas = ExcelReader(self.excel_path).data
        for d in datas:
            if d['run'].lower() == 'yes':
                with self.subTest(data=d['describe']):
                    url = self.API_UTL + d['api']
                    method = d['method']
                    data = d['data']
                    #判断excel上面的data不为空时执行获取datas,否则执行不传data的get方法
                    if data != '':
                        datas = self.excel_data[data]
                        if method == 'post':
                            res = HTTPClient(url=url, method=method).send(data=datas).json()
                        else:
                            res = HTTPClient(url=url, method=method).send(params=datas).json()
                    else:
                        res = HTTPClient(url=url, method=method).send().json()

                    logger.debug('响应code字段:%s'% res['code'])
                    assertHTTPCode(res)   #判断响应json数据中的code字段
Exemplo n.º 23
0
 def get_activity_index(self):
     '''救援活动id'''
     url = self.API_URL + 'activity/index'
     res = HTTPClient(url=url, method='get').send(params=self.token).json()
     try:
         dict_id = {
             'id': res['data'][1]['id'],
             'rule_id': res['data'][1]['rule'][0]['id']
         }
         datas = dict(self.token, **dict_id)
         return datas
     except Exception:
         pass
Exemplo n.º 24
0
 def get_activity_lucky(self):
     '''黄金转盘活动id'''
     url = self.API_URL + 'activity/index'
     res = HTTPClient(url=url, method='get').send(params=self.token).json()
     try:
         for i in res['data']:
             if i['activity_name'] == '黄金轮盘':
                 id = i['id']
         dict_id = {'id': id}
         datas = dict(self.token, **dict_id)
         return datas
     except Exception:
         pass
Exemplo n.º 25
0
class TestBaiDuHTTP(unittest.TestCase):
    URL = 'https://www.baidu.com'

    def setUp(self):
        warnings.simplefilter('ignore', ResourceWarning)

    def setUp(self):
        self.client = HTTPClient(url=self.URL, method='GET')

    def test_baidu_http(self):
        res = self.client.send()
        logger.debug(res.text)
        self.assertIn('百度一下,你就知道', res.text)
Exemplo n.º 26
0
class TestBaiDuHTTP(unittest.TestCase):
    URL = Settings().get('url',index=2) #设置url地址,正式用时去掉
    def setUp(self):
        self.client = HTTPClient(url=self.URL, method='GET',headers=None,cookies=None)

    def test_baidu_http(self):
        res = self.client.send(
            params='',
            dataType=None,
            data='')
        logger.debug(res.text)
        assertHTTPCode(res, [400]) #断言
        self.assertIn('百度一下,你就知道', res.text)
Exemplo n.º 27
0
 def get_platform_games_KY(self) -> dict:
     '''KY游戏id(三公)'''
     url = self.API_URL + 'platform/games'
     res = HTTPClient(url=url, method='get').send().json()
     try:
         for i in res['data']['AGIN']:
             if i['plat_code'] == 'KY':
                 code = i['code']
                 break
         dict_id = {'platform_played_id': code, 'platform_type': 'KY'}
         datas = dict(self.token, **dict_id)
         return datas
     except Exception:
         pass
    def test_xjx_borrowMoney2(self):
        addBorrowMoney = self.URL + self.addBorrowMoney_URL
        logger.info('开始执行新增app借款接口,caseName:test_xjx_borrowMoney2')
        self.client = HTTPClient(url=addBorrowMoney, method='POST')
        logger.info('请求的api路径为:{0}'.format(self.addBorrowMoney_URL))
        logger.info('拼接后的请求路径为:{0}'.format(addBorrowMoney))
        self.jsondata['speedStatus'] = ''
        self.jsondata['pay_password'] = '******'

        res = self.client.send(data=self.jsondata)
        logger.info('返回的参数为:{0}'.format(res.text))
        logger.info('接口入参为:query--{0}'.format(self.jsondata))

        self.assertIn('成功', res.text)

        item_message = self.j.extract(query='data.item.message', body=res.text)
        self.assertEqual(item_message, '申请成功')
        order_id = self.j.extract(query='data.item.order_id', body=res.text)
        logger.info('页面返回的order_id为:{0}'.format(order_id))
        select_orderid = "select id from asset_borrow_order where user_id = '768093098' ORDER BY id DESC LIMIT 1"
        logger.info('查询数据库数据的sql为:{0}'.format(select_orderid))
        db_order_id = self.get_dbdata.fetch_one(select_orderid)
        logger.info('查询数据库的数据,返回的order_id为:{0}'.format(db_order_id))
Exemplo n.º 29
0
class TestHTTP(unittest.TestCase):
    URL1 = "http://www.baidu.com"
    URL2 = "http://192.168.129.107:7950/abisweb"
    URL3 = "https://mvphjx.github.io/starDemo/LearnAndTest/notexist.html"

    def setUp(self):
        pass

    def subTest1(self):
        self.client = HTTPClient(url=self.URL1, method='GET')
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [200])
        self.assertIn('百度一下,你就知道', res.text)

    def subTest2(self):
        self.client = HTTPClient(url=self.URL2, method='GET')
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [200])
        self.assertIn('abisweb', res.text)

    def subTest3(self):
        self.client = HTTPClient(url=self.URL3, method='GET')
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [200])
        self.assertIn('github', res.text)

    def test_http(self):
        with self.subTest(data="百度"):
            self.subTest1()
        with self.subTest(data="abisweb"):
            self.subTest2()
        with self.subTest(data="github"):
            self.subTest3()
Exemplo n.º 30
0
class TestPrmHTTP(unittest.TestCase):

    excel = DATA_PATH + '/prm.xlsx'

    def sub_setUp(self):
        ''

    def sub_tearDown(self):
        ''

    def test_prm_http(self):
        URLS = ExcelReader(self.excel).data
        for u in URLS:
            with self.subTest(url=u):
                self.sub_setUp()
                self.client = HTTPClient(url=u['url'], method='GET')
                res = self.client.send()
                logger.debug(res.text)
                self.assertEqual(res.json()['status'], 'UP')
Exemplo n.º 31
0
class TestDdtHTTP(unittest.TestCase):
    URL1 = "http://www.baidu.com"
    URL2 = "http://192.168.129.107:7950X/abisweb"
    URL3 = "https://mvphjx.github.io/starDemo/LearnAndTest/notexist.html"

    def setUp(self):
        pass

    def subTestUrl(self, url):
        self.client = HTTPClient(url=url, method='GET')
        res = self.client.send()
        logger.debug(res.text)
        assertHTTPCode(res, [200])
        self.assertIn('百度一下,你就知道', res.text)

    @ddt.data(['http://www.baidu.com'], ['http://www.baidu.com'])
    @ddt.unpack
    def test_http(self, url):
        self.subTestUrl(url)
Exemplo n.º 32
0
 def setUp(self):
     self.client = HTTPClient(url=self.URL, method='GET')