def setUpClass(cls): Log().info("正在执行:登陆测试") # token=get_yaml_variable("X-SessionToken-With") # print("登陆后的token为:%s"%token) user_Session() cls.app_host = cls.app_host cls.User_session = { "X-SessionToken-With": get_yaml_variable("X-SessionToken-With") } cls.app_headers.update(cls.User_session) print(cls.app_headers)
def test_Dingjia_auditPass(self): """ 定价申请审核通过 :return: """ lujing = '/cms/dealerCarEnquiry/operateDealerCarEnquiry' sq_id = get_yaml_variable("data") data = {"id": sq_id, "status": "PASSED", "remark": "自动化通过"} res = self.session.post(self.cms_host + lujing, data) response = json.loads(res.text) self.assertTrue(str(response['code']) == '200', msg='状态不对') self.assertIn('success', response['msg'], msg='a不在b中') print(response)
def setUpClass(cls): with open('{}'.format( os.path.join(os.path.dirname(os.getcwd()), 'Config') + '\conf.yaml'), 'r', encoding="utf-8") as r: config = yaml.load(r) # 解析并读写yaml文件 cls.app_host = config['cms_host'] cls.cms_headers = eval(config['cms_headers']) cls.session = cms_cookies() cls.cms_headers['Authorization'] = get_yaml_variable('Authorization') cls.stationName = "野风时代" + str(random.randint(1, 1000)) cls.spot_code = random.randint(100000, 999999) return cls.cms_headers
def setUpClass(cls): Log().info("正在执行:登陆测试") dealer_Session() #登陆写入session # token=get_yaml_variable("X-SessionToken-With") # print("登陆后的token为:%s"%token) cls.app_host = cls.app_host cls.cms_host = cls.cms_host cls.Dealer_session = { "X-SessionToken-With": get_yaml_variable("X-SessionToken-With") } cls.app_headers.update(cls.Dealer_session) cls.session = cms_cookies() #将获取的cookie设置为session变量全局使用
def test_shenqing_details(self): ''' 采销后台打开申请详情 :return: ''' sq_id = get_yaml_variable("data") lujing = '/cms/dealerCarEnquiry/getDetail/' + sq_id # print(lujing) res = self.session.get(self.cms_host + lujing) response = json.loads(res.text) #res.text 为str格式 json。loads()将str-dict self.assertTrue(str(response['code']) == '200', msg='状态不对') self.assertIn('success', response['msg'], msg='a不在b中') self.assertIn("'statusName': '待平台定价审核'", str(response['data']), msg='a不在b中') print(response['data']['applyNo'])
def test_change_headshot(self): """ 更改头像 获取时间戳-上传凭证——上传七牛——返回key——上传服务器 :return: """ key = get_yaml_variable("key") # print(key) url = self.app_host + '/dealer/upInfo' image = "http:\/test-oss.mofangcar.com\/" + key print(image) datas = {"headImage": image} # print(datas) #此处加了一个变量 自动变为单引号了 但请求必须为双引号的json数据类型啊!!!! # data = json.dumps(datas) #所以必须使用json.dumps 变为 json数据类型 或者下面json=datas也行 # print(data) # print(type(data)) headers = self.app_headers res = requests.put(url, json=datas, headers=headers) print(res.json())