コード例 #1
0
 def test_user_register_login_list(self, testcase_data):
     username = testcase_data["username"]
     password = testcase_data["password"]
     telephone = testcase_data["telephone"]
     sex = testcase_data["sex"]
     address = testcase_data["address"]
     except_result = testcase_data["except_result"]
     except_code = testcase_data["except_code"]
     except_msg = testcase_data["except_msg"]
     logger.info("*************** 开始执行用例 ***************")
     result = register_user(username, password, telephone, sex, address)
     step_1(username, password, telephone, sex, address)
     assert result.success is True, result.error
     result = login_user(username, password)
     step_2(username)
     assert result.success is True, result.error
     result = get_one_user_info(username)
     step_3(username)
     assert result.success == except_result, result.error
     logger.info("code ==>> 期望结果:{}, 实际结果:【 {} 】".format(
         except_code,
         result.response.json().get("code")))
     assert result.response.json().get("code") == except_code
     assert except_msg in result.msg
     logger.info("*************** 结束执行用例 ***************")
コード例 #2
0
 def test_user_register_login_update_fail(self, testcase_data):
     username = testcase_data["register"]["username"]
     password = testcase_data["register"]["password"]
     telephone = testcase_data["register"]["telephone"]
     sex = testcase_data["register"]["sex"]
     address = testcase_data["register"]["address"]
     admin_user = testcase_data["login"]["admin_user"]
     admin_pwd = testcase_data["login"]["admin_pwd"]
     new_password = testcase_data["update"]["new_password"]
     new_telephone = testcase_data["update"]["new_telephone"]
     new_sex = testcase_data["update"]["new_sex"]
     new_address = testcase_data["update"]["new_address"]
     except_result = testcase_data["except_result"]
     except_code = testcase_data["except_code"]
     except_msg = testcase_data["except_msg"]
     logger.info("*************** 开始执行用例 ***************")
     result = register_user(username, password, telephone, sex, address)
     step_1(username, password, telephone, sex, address)
     assert result.success is True, result.error
     result = login_user(admin_user, admin_pwd)
     step_2(admin_user)
     assert result.success is True, result.error
     admin_token = result.token
     result = get_one_user_info(username)
     id = result.response.json().get("data")[0].get("id")
     step_3(id)
     assert result.success is True, result.error
     result = update_user(id + 1, admin_user, new_password, new_telephone, admin_token, new_sex, new_address)
     step_4(id)
     assert result.success == except_result, result.error
     logger.info("code ==>> 期望结果:{}, 实际结果:【 {} 】".format(except_code, result.response.json().get("code")))
     assert result.response.json().get("code") == except_code
     assert except_msg in result.msg
     logger.info("*************** 结束执行用例 ***************")
コード例 #3
0
 def test_get_get_one_user_info(self, username, except_result, except_code,
                                except_msg):
     logger.info("*************** 开始执行用例 ***************")
     step_2(username)
     result = get_one_user_info(username)
     # print(result.__dict__)
     assert result.response.status_code == 200
     assert result.success == except_result, result.error
     logger.info("code ==>> 期望结果:{}, 实际结果:【 {} 】".format(
         except_code,
         result.response.json().get("code")))
     assert result.response.json().get("code") == except_code
     assert except_msg in result.msg
     logger.info("*************** 结束执行用例 ***************")