Пример #1
0
 def hash_del(self, name, k):
     res = self.r.hdel(name, k)
     if res:
         LOG.info('删除成功')
         return 1
     else:
         LOG.info('删除失败,该key不存在')
         return 0
Пример #2
0
 def wrapper(*args, **kw):
     for i in range(n):
         try:
             r = func(*args, **kw)
             return r
         except AssertionError as err:
             LOG.info('用例第%d次失败原因:%s' % (i + 1, err))
     raise AssertionError
Пример #3
0
 def getresult(self):
     try:
         result = HessianProxy(self.url + self.interface)
         return_result = getattr(result, self.method)(self.interface_param)
         LOG.info('测试返回结果:%s' % return_result)
         res = {'code': 0, 'result': return_result}
     except Exception as e:
         LOG.info('测试失败,原因:%s' % e)
         res = {'code': 1, 'result': e}
     return res
Пример #4
0
 def test_sign_params_null(self, _, data_params):
     '''验证报名各字段参数为空'''
     uri = '/bentley/api/applyForTcjAsyn/'
     response = requests.post(self.url + uri,
                              data=data_params,
                              headers=self.headers)
     LOG.info('请求{0},参数{1},状态{2},\n 响应数据{3}'.format(uri, data_params,
                                                    response,
                                                    response.text))
     self.assertEqual(response.status_code, 200, '断言响应结果为200')
     self.assertEqual(response.json()['code'], 100000, '断言结果为100001')
     self.assertEqual(response.json()['msg'], '参数异常', '断言参数异常')
Пример #5
0
 def test_signed(self):
     '''验证已经报名过重复报名'''
     uri = '/bentley/api/applyForTcjAsyn/'
     data_params = {
         'name': 'linlang66',
         'phone': '15633996699',
         'cityId': 10,
         'carStyleId': 32,
         'brandId': 67,
         'groupbyType': 1,
         'groupbyNum': 2001
     }
     response = requests.post(self.url + uri,
                              data=data_params,
                              headers=self.headers)
     LOG.info('请求{0},参数{1},状态{2},\n 响应数据{3}'.format(uri, data_params,
                                                    response,
                                                    response.text))
     self.assertEqual(response.status_code, 200, '断言响应结果为200')
     self.assertEqual(response.json()['code'], 100000, '断言结果为100000')
Пример #6
0
def send_mail():
    suite_result = test_runner()
    to_list = ConfigOperate('global').get_config('email_send',
                                                 'to_list').split(';')
    cc_list = ConfigOperate('global').get_config('email_send',
                                                 'cc_list').split(';')
    file_path_tuple = (report_file_name, )
    email_username = ConfigOperate('global').get_config(
        'email_base', 'username')
    email_passwd = ConfigOperate('global').get_config('email_base', 'passwd')
    email_smtp = ConfigOperate('global').get_config('email_base', 'smtp')
    send_conf = SendEmail(email_smtp, email_username, email_passwd)
    content = 'http接口自动化测试完成,测试通过:%s,测试失败:%s,未知错误:%s,详情见附件' % (
        suite_result.success_count, suite_result.failure_count,
        suite_result.error_count)
    if send_conf.send_email(to_list,
                            cc_list,
                            sub='接口自动化测试报告' + now,
                            content=content,
                            file_path=file_path_tuple
                            ):  # content=open(report_file_name, 'rb').read()
        LOG.info('测试报告邮件发送成功')
    else:
        LOG.info('邮件发送失败')
Пример #7
0
 def clean_redis(self):
     self.r.flushdb()  # 清空 redis
     LOG.info('清空redis成功!')
     return 0