def setUp(self): """ 登录取得token :return: """ print("测试开始") response = ConsultationAss().login(method=self.method, url=self.url, data=self.data) res = get_result_for_keyword(response, 'token') self.token = {'Authorization': res} response = ConsultationAss().get_consultationAss(self.token) self.consultationAss_id = get_result_for_keyword(response, 'id')
def test_02_check(self): """查看咨询""" header = self.token response = Consultation().check_consultation(header) result = json.dumps(response, ensure_ascii=False, indent=2) code = get_result_for_keyword(response, 'code') res = get_result_for_keyword(response, 'msg') result = {'code': code, 'msg': res} if self.assertEqual(res, "查询成功") == None: print('断言成功,接口正常请求') print('咨询查看的接口返回参数为:', result) else: print('断言失败')
def setUp(self): """ 登录取得token :return: """ print("测试开始") response = Preparation().login(method=self.method, url=self.url, data=self.data) res = get_result_for_keyword(response, 'token') self.token = {'Authorization': res} response = Preparation().all_preparation(self.token) # response = response.json() self.userid = get_result_for_keyword(response, 'id')
def test_02_check(self): """查看预约""" header = self.token response = Bespeak ().get_bespeak (header) result = json.dumps (response, ensure_ascii=False, indent=2) code = get_result_for_keyword (response, 'code') res = get_result_for_keyword (response, 'msg') result = { 'code': code, 'msg': res } if self.assertEqual (code, 10001) == None: print ('断言成功,接口正常请求') print ("预约成功,返回数据为:", result) else: print ('断言失败')
def setUp(self): """ 登录取得token :return: """ print("测试开始") response = Reception().login(method=self.method, url=self.url, data=self.data) res = get_result_for_keyword(response, 'token') self.token = {'Authorization': res} response = Reception().get_reception(self.token) if_id = get_result_for_keyword(response, 'total') if if_id == 0: print('当前没有接待') else: self.reception_id = get_result_for_keyword(response, 'id')
def test_07_verification(self): """核销""" header = self.token response = Interface().verification(header) result = json.dumps(response, ensure_ascii=False, indent=2) # print(result) res = get_result_for_keyword(response, 'msg') # if self.assertEqual(res, "操作成功") == None: print("核销成功")
def test_06_payment(self): """缴费""" header = self.token response = Interface().payment(header) result = json.dumps(response, ensure_ascii=False, indent=2) print("对缴费是否成功进行断言") # print(result) res = get_result_for_keyword(response, 'msg') # if self.assertEqual(res, "操作成功") == None: print("缴费成功")
def test_03_update(self): """修改咨询数据""" header = self.token response = Consultation().update_consultation(header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if self.assertEqual(res, "操作成功") == None: print('断言成功,接口正常请求') print('返回结果为:', result) else: print('断言失败')
def setUp(self): """ 登录取得token :return: """ print ("测试开始") response = Bespeak ().login (method=self.method, url=self.url, data=self.data) res = get_result_for_keyword (response, 'token') self.token = { 'Authorization': res }
def test_01_add(self): """新增面诊""" header = self.token response = ConsultationAss().add_consultationAss(header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if self.assertEqual(res, "操作成功") == None: print('断言成功,接口正常请求') print('请求返回数据为:', result) else: print('断言失败')
def update_preparation(self, header=None): """修改报备的接口""" url = "http://test.api.neurongenius.com/api/v1/preparation/update" data = { "customerName": [{ "name": "王建国", "ismain": 1 }], "comeDate": "", "projectIds": ["dict_04a4a7b39efb6221db26b9ea3bfebd2a"], "preTypeId": "5", "remark": "", "preUserId": "9d84c6ac6e0d2696ba815c935408417e", "preDeptId": "bfb24660a14d9be2f9d2e7a0af7e4b87", "fileId": [], "customerPhone": [{ "phone": "18512385958", "ismain": 1 }], "id": "1dce9306777b67ad79b65c8a3758da18", "sourceTypeDetailType": "" } method = 'post' # pre_name = get_result_for_keyword(data,'name') # pre_phone = get_result_for_keyword(data,"phone") # print("修改前名字为:",pre_name) # print("修改前手机号为:",pre_phone) data['customerName'][0]['name'] = f.name_male() data['customerPhone'][0]['phone'] = f.phone_number() after_name = get_result_for_keyword(data, 'name') after_phone = get_result_for_keyword(data, "phone") print("修改后名字为:", after_name) print("修改后手机号为:", after_phone) data = str(data) data = data.encode() # id = get_result_for_keyword(data,'id') response = RunMain().run_main(method=method, url=url, data=data, header=header) return response
def test_01_add(self): """新增接待""" header = self.token response = Reception().add_reception(header) result = json.dumps(response, ensure_ascii=False, indent=2) print(result) res = get_result_for_keyword(response, 'msg') if res == '新建接待成功' or '该客户已有接待信息': self.assertTrue(1) print('断言成功,接口正常请求') else: print('断言失败')
def test_03_update(self): """编辑报备信息接口""" header = self.token response = Preparation().update_preparation(header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') res1 = '修改成功' if self.assertEqual(res, res1) == None: print("断言成功") print('新增成功,返回参数为:', result) else: print("断言失败,请检查接口是否请求")
def test_03_update(self): """修改预约数据""" header = self.token response = Bespeak ().update_bespeak (header) result = json.dumps (response, ensure_ascii=False, indent=2) print (result) res = get_result_for_keyword (response, 'msg') if self.assertEqual (res, "操作成功") == None: print ('断言成功,接口正常请求') print ("预约成功") else: print ('断言失败')
def test_04_delete(self): """删除预约数据""" header = self.token response = Bespeak ().delete_bespeak (header) result = json.dumps (response, ensure_ascii=False, indent=2) # print (result) res = get_result_for_keyword (response, 'code') if self.assertEqual (res, 20002) == None: print ('断言成功,接口正常请求') print ("预约成功") else: print ('断言失败')
def test_02_order(self): """预约""" response = Interface().order() result = json.dumps(response, ensure_ascii=False, indent=2) print(result) res = get_result_for_keyword(response, 'msg') self.assertEqual(res, '新建预约成功') # 对结果进行断言 if self.assertEqual(res, "新建预约成功") == None: print('断言成功,接口正常请求') print("预约成功") else: print('断言失败')
def test_02_check(self): """查看面诊""" header = self.token consultationAss_id = self.consultationAss_id response = ConsultationAss().check_consultationAss( consultationAss_id, header).json() result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'code') if self.assertEqual(res, 10001) == None: print('断言成功,接口正常请求') print('该条面诊记录为:', result) else: print('断言失败')
def test_04_delete(self): """删除报备信息接口""" header = self.token uid = self.userid response = Preparation().delete_preparation(uid, header) response = response.json() result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if self.assertEqual(res, '删除成功') == None: print('断言成功') print("删除报备接口正常,返回参数为:", result) else: print('断言失败')
def test_02_check(self): """查看接待""" header = self.token reception_id = self.reception_id response = Reception().check_reception(reception_id, header) response = response.json() result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if self.assertEqual(res, "操作成功") == None: print('断言成功') print('查看接待成功请求,返回数据为:', result) else: print('断言失败')
def test_01_add(self): """新增预约""" header = self.token response = Bespeak ().add_bespeak (header) result = json.dumps (response, ensure_ascii=False, indent=2) print (result) res = get_result_for_keyword (response, 'msg') self.assertEqual (res, '新建预约成功') # 对结果进行断言 if self.assertEqual (res, "新建预约成功") == None: print ('断言成功,接口正常请求') print ("预约成功") else: print ('断言失败')
def test_02_check(self): """查看报备接口""" header = self.token # id = self.userid response = Preparation().check_preparation(header) response = response.json() result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if self.assertEqual(res, '查询成功') == None: print('断言成功') print("查看报备接口正常,返回参数为:", result) else: print('断言失败')
def test_04_delete(self): """删除咨询数据""" header = self.token response = Consultation().delete_consultation(header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if res == '数据不存在或错误': self.assertTrue(1) print('接口正常请求') elif res == '已处理不能作废': self.assertTrue(1) print('接口正常请求') else: print('断言失败')
def test_03_update(self): """修改面诊数据""" header = self.token consultationAss_id = self.consultationAss_id if_uid = ConsultationAss().sure_consultationAss( consultationAss_id, header) print(if_uid) response = ConsultationAss().update_consultationAss(header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if self.assertEqual(res, "操作成功") == None: print('断言成功,接口正常请求') print('修改面诊后返回参数:', result) else: print('断言失败')
def setUp(self): """ 将登录放在这里,在每次执行用例之前执行 :return: """ print("测试开始") response = Interface().login(method=self.method, url=self.url, data=self.data) # print(type(response)) # print(response) # res = json.loads(response) res = get_result_for_keyword(response, 'token') # res1 = get_results_for_keyword(response, 'id')[-1] # res2 = get_results_for_keyword(response, 'depts')[0][0] self.token = { 'Authorization': res }
def test_03_update(self): """修改接待数据""" header = self.token reception_id = self.reception_id response = Reception().update_reception(reception_id, header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if res == '保存成功': self.assertTrue(1) print('断言成功,接口正常请求') print('接口返回数据为:', result) elif res == '客户已完成接诊,无法修改': self.assertTrue(1) print('断言成功,接口正常请求') print('接口返回数据为:', result) else: print('断言失败')
def test_04_consultation(self): """ 咨询 :return: """ header = self.token response = Interface().consultation(header) result = json.dumps(response, ensure_ascii=False, indent=2) res = get_result_for_keyword(response, 'msg') if res == '已经有该客户咨询': self.assertTrue(1) print ("接口请求成功") print ("但是当前已有该客户咨询") elif res== '操作成功': print("接口请求成功") print("返回数据为:",result) else: print('断言失败')
def test_04_delete(self): """删除接待数据""" header = self.token reception_id = self.reception_id response = Reception().delete_reception(reception_id, header).json() result = json.dumps(response, ensure_ascii=False, indent=2) # print (result) res = get_result_for_keyword(response, 'msg') if res == '操作成功': self.assertTrue(1) print('断言成功,接口正常请求') print('接口返回数据为:', result) elif res == '当前接待已产生业务,不能作废': self.assertTrue(1) print('断言成功,接口正常请求') print('接口返回数据为:', result) else: print('断言失败')