コード例 #1
0
ファイル: testFeedBack.py プロジェクト: xgh321324/api_test
class Feedback(unittest.TestCase):
    def setUp(self):
        self.s = requests.session()
        self.lgin = LG(self.s)  #实例化登录类
        self.uid_token = self.lgin.get_token()  #直接取账号登录的token
        self.auto_login_token = self.lgin.get_autologin_token()  #取自动登录的token
        self.header = {
            'User-Agent': 'LanTingDoctor/2.0.2 (iPad; iOS 10.1.1; Scale/2.00)',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'zh-Hans-CN;q=1',
            'Content-Type': 'application/json',
            'requestApp': '3',
            'requestclient': '2',
            'versionForApp': '2.0',
            'Authorization':
            'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=',
            'Connection': 'keep-alive'
        }
        self.log = Log()

    @unittest.skip('无理由跳过!')
    def test_feedback(self):
        u'测试一键反馈接口'
        self.log.info('测试意见反馈只反馈文字')
        url = 'http://api.rih.medohealth.com/API/V1/UserFeedBack/addAUserFeedBack'
        json_data = {
            "ufbTitle": "反馈信息",
            "ufbUIUID": "IKxSa8XhbiJH1CYlwQvkW50oLefZ62uB",
            "ufbDesc": "urjrjfjfjfjfjfjrjrjjffjj",
            "token": self.auto_login_token,
            "ufbImages": "[]",
        }
        r = self.s.post(url, headers=self.header, json=json_data)
        print(r.json())
        self.assertEqual('反馈成功', r.json()['msg'], msg='只反馈文字出错了')
        self.log.info('意见反馈只反馈文字成功!')

        self.log.info('测试意见反馈反馈图片和文字:')
        json_data2 = {
            "ufbTitle": "反馈信息",
            "ufbUIUID": "IKxSa8XhbiJH1CYlwQvkW50oLefZ62uB",
            "ufbDesc": "南京今天",
            "ufbImages": "[\"feedbackimages\/23411.png\"]",
            "token": ""
        }
        r2 = self.s.post(url, headers=self.header, json=json_data2)
        print('r2', r2.json())
        self.assertEqual('反馈成功', r.json()['msg'], msg='反馈出错了')
        self.log.info('测试意见反馈反馈图片和文字成功!')

    def tearDown(self):
        self.s.close()
コード例 #2
0
ファイル: testTrainPlan.py プロジェクト: xgh321324/api_test
class Trian(unittest.TestCase):
    def setUp(self):
        self.s = requests.session()
        self.lgin = LG(self.s)  #实例化登录类
        self.uid_token = self.lgin.get_token()  #直接取账号登录的token
        self.auto_login_token = self.lgin.get_autologin_token()  #取自动登录的token
        self.header = {
            'User-Agent': 'LanTingDoctor/2.0.2 (iPad; iOS 10.1.1; Scale/2.00)',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'zh-Hans-CN;q=1',
            'Content-Type': 'application/json',
            'requestApp': '3',
            'requestclient': '2',
            'versionForApp': '2.0',
            'Authorization':
            'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=',
            'Connection': 'keep-alive'
        }
        self.log = Log()
        self.excel = Excel_util(
            r'C:\Users\Administrator\Desktop\Interface_testcase.xls')

    def test_get_user_plan(self):
        u'医生获取用户训练方案接口'
        self.log.info('开始测试医生查看用户训练方案接口.....')

        #'这是获取已绑定的列表'
        url = 'http://api.rih.medohealth.com/API/V1/DoctorToUserReleationShip/getReleathionShipInfo'
        json_data = {"token": self.auto_login_token}
        r = self.s.post(url, headers=self.header, json=json_data)
        Patients = r.json()['data']
        User_UID = []
        for i in Patients:
            User_UID.append(i['UserUID'])
        print(User_UID)

        #判断当前医生是否有绑定的用户来执行不同操作
        if len(User_UID) >= 1:
            #当绑定不为空时,医生再去获取用户的方案
            for id in User_UID:
                url_2 = 'http://api.rih.medohealth.com/API/V1/UserTrainCourse/getUserTrainCourseByDoctor'
                json_data_2 = {"token": self.auto_login_token, "userUID": id}
                r2 = self.s.post(url_2, headers=self.header, json=json_data_2)
                self.assertEqual(200, r2.json()['code'])
                plans = r2.json()['data']
            #将方案的course id写入excel供调用
            course_ids = {}
            n = 1
            for p in plans:
                #print(p)
                course_ids['corse_id_' + str(n)] = p['utcUID']
                n += 1
            self.excel.write_value(11, 6, course_ids)

        else:
            self.log.warning('该医生还没有绑定的用户!')

        self.log.info('医生查看用户训练方案接口测试结束!')

    def test_get_doctor_plan(self):
        u'医生获取训练方案接口'
        self.log.info('开始测试医生的训练方案接口.....')
        url = 'http://api.rih.medohealth.com/API/V1/DoctorTrainCourse/getTrainCourseForDoctor'
        json_data = {"token": self.auto_login_token}
        r = self.s.post(url, headers=self.header, json=json_data)
        print(r.json())
        self.assertEqual(200, r.json()['code'])
        self.log.info('医生的训练方案接口测试结束!!')

    def tearDown(self):
        self.s.close()
コード例 #3
0
class ConfigInfo(unittest.TestCase):
    def setUp(self):
        self.s = requests.session()
        self.lgin = LG()  #实例化登录类
        self.uid_token = self.lgin.get_token()  #直接取账号登录的token
        self.auto_login_token = self.lgin.get_autologin_token()  #取自动登录的token
        self.header = {
            'User-Agent': 'LanTingDoctor/2.0.2 (iPad; iOS 10.1.1; Scale/2.00)',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'zh-Hans-CN;q=1',
            'Content-Type': 'application/json',
            'requestApp': '3',
            'requestclient': '2',
            'versionForApp': '2.0',
            'Authorization':
            'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=',
            'Connection': 'keep-alive'
        }
        self.log = Log()

    @unittest.skip('无条件跳过')
    def test_config_info(self):
        u'设置医生实名认证信息接口'
        self.log.info('开始测试医生实名认证接口.....')
        url = 'http://api.rih.medohealth.com/API/V1/DoctorInfo/setDoctorInfoandTitle'
        json_data = {
            "id_card": "321324199103041432",
            "image":
            "RightInDoctrorFiles\/Distribute\/TitleAuthentication\/IKxSa8XhbiJH1CYlwQvkW50oLefZ62uB\/84810175026042607520180515134933.png",
            "huid": "A596D422B726308EA01A9EB27D4417C0",
            "key": random.randint(0, 9),
            "token": self.auto_login_token,
            "kuid": "457BDE586E8AD22B683AB5740EDBA9F9",
            "name": "许家印"
        }
        r = self.s.post(url, headers=self.header, json=json_data)
        print(r.json())
        self.assertEqual('更新医生资料成功', r.json()['msg'])
        self.log.info('医生实名认证接口测试结束!')

    @unittest.skip('无条件跳过')
    def test_doctor_profession(self):
        u'设置医生职称接口'
        self.log.info('开始测试设置医生职称.....')
        url = 'http://api.rih.medohealth.com/API/V1/DoctorInfo/SetDoctorTitle'
        json_data = {
            "token": self.auto_login_token,
            "duid": "IKxSa8XhbiJH1CYlwQvkW50oLefZ62uB",
            "data": [{
                #"image":'',
                "key": "learn",
                "code": random.randint(0, 6)
            }]
        }
        r = self.s.post(url, headers=self.header, json=json_data)
        print(r.json())

        self.log.info('设置医生职称接口测试结束!')

    def tearDown(self):
        self.s.close()