def test_user_reg_normal(self): case_data = load_data.get_case(self.sheet, "test_user_reg_normal") NAME = "消防队1202" if db.check_user(NAME): # 环境准备,检查数据是否存在 db.del_user(NAME) url = case_data[2] data = json.loads(case_data[3]) excepted = json.loads(case_data[4]) #预期结果 res = requests.post(url=url, json=data) # try: # data = json.loads(case_data[3]) # excepted_res = json.loads(case_data[4]) # except json.decoder.JSONDecodeError as e: # config.logging.error("用例数据不是合法json") # # res = requests.post(url=url, json=data) # log_case_info("test_user_reg_normal", url, case_data[3], case_data[4], res.text) # try: # res_json = res.json() # except json.decoder.JSONDecodeError as e: # config.logging.error("返回结果不是json格式") case_log.log_case_info("test_user_reg_normal", url, case_data[3], case_data[4], res.text) self.assertEqual("成功", res.json()["msg"]) self.assertDictEqual(excepted, res.json()) self.assertTrue(db.check_user(NAME)) db.del_user(NAME) # 环境清理
def test_user_reg_normal(self): if db.check_user("张三丰"): db.del_user("张三丰") case_data = load_data.get_case(self.sheet, "test_user_reg_normal") url = case_data[2] # try: # data = json.loads(case_data[3]) # excepted_res = json.loads(case_data[4]) # except json.decoder.JSONDecodeError as e: # config.logging.error("用例数据不是合法json") # # res = requests.post(url=url, json=data) # log_case_info("test_user_reg_normal", url, case_data[3], case_data[4], res.text) # try: # res_json = res.json() # except json.decoder.JSONDecodeError as e: # config.logging.error("返回结果不是json格式") data = json.loads(case_data[3]) excepted_res = json.loads(case_data[4]) res = requests.post(url=url, json=data) log_case_info("test_user_reg_normal", url, case_data[3], case_data[4], res.text) self.assertDictEqual(excepted_res, res.json()) db.del_user("张三丰") # 环境清理
def test_user_reg_normal(self): case_data = load_data.get_case(self.sheet, "test_user_reg_normal") url = case_data[2] data = json.loads(case_data[3]) excepted_res = json.loads(case_data[4]) res = requests.post(url=url, json=data) self.assertDictEqual(excepted_res, res.json()) db.del_user("张三丰") # 环境清理
def test_user_reg_normal(self): NAME = "张三丰" if db.check_user(NAME): # 环境准备 db.del_user(NAME) url = 'http://115.28.108.130:5000/api/user/reg/' data = {"name": NAME, "password": "******"} res = requests.post(url=url, json=data) self.assertEqual("成功", res.json()["msg"]) self.assertTrue(db.check_user(NAME)) db.del_user(NAME) # 环境清理
def test_reg_success(self): case_data=load_data.get_case(self.sheet,"test_reg_success") NAME="test100" if check_user(NAME): del_user(NAME) url =case_data[2] data=json.loads(case_data[3]) excepted_res=json.loads(case_data[4]) res=requests.post(url=url,json=data) self.assertDictEqual(excepted_res,res.json()) #数据清理 del_user("test100")
def test_user_reg_normal(self): case_data = load_data.get_case(self.sheet, "test_user_reg_normal") # NAME = "张三丰" # if db.check_user("张三丰"): # 环境准备 # db.del_user("张三丰") url = case_data[2] data = json.loads(case_data[3]) excepted_res = json.loads(case_data[4]) res = requests.post(url=url, json=data) self.assertEqual(excepted_res, res.json()) # self.assertTrue(db.check_user(NAME)) db.del_user("张三丰") # 环境清理
def test_tied_card_normal(self): case_data = load_data.get_case(self.sheet,'test_tied_card_normal') url = case_data[2] data = json.loads(case_data[3]) excepted_res = json.loads(case_data[4]) res = requests.post(url= url,json=data) log_case_info('test_tied_card_normal',case_data[2],case_data[3],case_data[4],res.json()) print(res.json()) self.assertDictEqual(excepted_res,res.json()) # self.assertEqual(res.json()['msg'],'绑定成功') self.assertTrue(chack_user('victor12')) del_user('Victor12') up_card('6216600411129')
def test_user_reg_normal(self): if db.check_user("张三丰"): db.del_user("张三丰") case_data = load_data.get_case(self.sheet, "test_user_reg_normal") url = case_data[2] data = json.loads(case_data[3]) excepted_res = json.loads(case_data[4]) res = requests.post(url=url, json=data) log_case_info("test_user_reg_normal", url, case_data[3], case_data[4], res.text) self.assertDictEqual(excepted_res, res.json()) db.del_user("张三丰") # 环境清理
def test_user_reg_normal(self): case_data = load_data.get_case(self.sheet,"test_user_reg_normal") # NAME = "张三丰" # if db.check_user(NAME): # 环境准备 # db.del_user(NAME) url = case_data[2] try: data = json.loads(case_data[3]) excepted_res = json.loads(case_data[4]) except json.decoder.JSONDecodeError as e: config.logging.error("用例数据不是合法json") res = requests.post(url=url, json=data) self.assertEqual("成功", res.json()["msg"]) self.assertTrue(db.check_user(NAME)) db.del_user(NAME) # 环境清理
def handle_remove_vk_user(vk_user_id): vk_user_id = int(vk_user_id) acct = context.accounts.get(vk_user_id) if not acct: _logger.info('User not found: %d', vk_user_id) return False asyncio.ensure_future(remove_tg_user(vk_user_id))\ .add_done_callback(lambda res: res.result() and db.del_user(vk_user_id)) return True
def test_user_reg_normal(self): #获取用例中需要清理的姓名 name_cell = self.sheet.cell(1, 3).value NAME = json.loads(name_cell)['name'] if db.check_user(NAME): # 环境准备 db.del_user(NAME) case_data = load_data.get_case(self.sheet, "test_user_reg_normal") url = case_data[2] try: data = json.loads(case_data[3]) excpeted_res = json.loads(case_data[4]) except json.decoder.JSONDecodeError as e: config.logging.error("用例数据不是合法json") res = requests.post(url=url, json=data) log_case_info("test_user_reg_normal", url, case_data[3], case_data[4], res.text) try: res_json = res.json() except json.decoder.JSONDecodeError as e: config.logging.error("返回结果不是json格式") self.assertEqual(excpeted_res, res_json) self.assertTrue(db.check_user(NAME)) db.del_user(NAME) # 环境清理
def test_user_reg_normal(self): if db.check_user("张三丰"): # 环境准备 db.del_user("张三丰") case_data = load_data.get_case(self.sheet, "test_user_reg_normal") url = case_data[2] try: data = json.loads(case_data[3]) excepted_res = json.loads(case_data[4]) except json.decoder.JSONDecodeError as e: config.logging.error("用例数据不是合法json") # url = 'http://115.28.108.130:5000/api/user/reg/' # data = {"name": NAME, "password": "******"} res = requests.post(url=url, json=data) # self.assertEqual("成功", res.json()["msg"]) # self.assertTrue(db.check_user(NAME)) self.assertDictEqual(excepted_res, res.json()) log_case_info("test_user_reg_normal", url, case_data[3], case_data[4], res.text) try: res_json = res.json() except json.decoder.JSONDecodeError as e: config.logging.error("返回结果不是json格式") db.del_user("张三丰") # 环境清理