def login_arize_install_impl() -> dict: """ Call api "login" to implement installer login. A dict will be returned, and keys are: - client - account_id - token """ client: Client = get_client_from_orm_by_id(2) # login # login_result = LoginArizeInstall() # login_result.config.variables(**{ # "client": client # }) # login_result.test_start() login_result = ( LoginArizeInstall() .with_variables(**{ "client": client, }) .run() ) # {"account_id": ?, "token": ?} token_dict = get_sub_dict(login_result.get_export_variables(), *['account_id', 'token']) yield { **token_dict, "client": client }
def login_operation_om_impl() -> dict: """ Login the om user. A dict will be returned, and keys are: - client - account_id - token """ # login om client: Client = get_client_from_orm_by_id(1) username = "******" login_om = TestLoginOperationRecipeMsSuccessfully() login_om.config.variables(**{ "client": client, "username": username }) login_om.run() # {"account_id": ?, "token": ?} token_om_dict = get_sub_dict(login_om.get_export_variables(), *['account_id', 'token', 'user_info']) yield { **token_om_dict, "client": client, }
def login_push_operation_user_impl() -> dict: """ login push background management user. A dict will be returned, and keys are: - client - account_id - token - username - password """ client: Client = get_client_from_orm_by_id(2) # login login = LoginOperationPushOm() login.config.variables(**{ "client": client }) login.test_start() # {"account_id": ?, "token": ?} token_dict = get_sub_dict(login.get_export_variables(), *['account_id', 'token']) yield { **token_dict, "client": client }
def register_login_new_user_impl() -> dict: """ Create a new user, register the new user and log in. My own home id will be yield too. A dict will be returned, and keys are: - client - account_id - token - email - password - home_id """ client: Client = get_client_from_orm_by_id(3) email = generate_email() password = "******" # register user register = TestRegisterNewUserSuccessfully() register.config.variables(**{ "client": client, "email": email, "password": password }) register.test_start() # login login = LoginV2() login.config.variables(**{ "client": client, "email": email, "password": password }) login.test_start() # {"account_id": ?, "token": ?} token_dict = get_sub_dict(login.get_export_variables(), *['account_id', 'token']) get_home_list = GetHomeList() get_home_list.config.variables(**token_dict, client=client) get_home_list.test_start() my_own_home_id = get_home_list.get_export_variables()["my_own_home_id"] yield { **token_dict, "email": email, "password": password, "client": client, "home_id": my_own_home_id } # delete user delete_user = DeleteUser() delete_user.with_variables({}) # get rid of the effect on session variables from previous instances delete_user.config.variables(client=client, **token_dict) delete_user.test_start()
def setup(reset_award_odds_and_stock_scope_class, register_login_new_users_and_complete_lottery_scope_package, request): expected_lottery_prize_people_list = \ register_login_new_users_and_complete_lottery_scope_package["expected_lottery_prize_people_list"] config: Config = request.cls.config config.variables( **get_sub_dict( register_login_new_users_and_complete_lottery_scope_package[ "user_list"][0], *["account_id", "token"]), client=get_client_from_orm_by_id(1), expected_lottery_prize_people_list=expected_lottery_prize_people_list)
class TestAuthentication(HttpRunner): config = (Config("鉴权测试用例集").variables( **{ "client": get_client_from_orm_by_id(1), "account_id": None, "token": None, "award_pool_name": anniversary_draw_settings.award_pool_name, "task_block": "$award_pool_name", "event": anniversary_draw_settings.event_browse_mall, "trigger_source": "$award_pool_name", })) teststeps = [ Step( RunApiSignUpActivity( "未鉴权用户进行预约").request().validate().assert_startswith( "body.code", "-11000")), Step( RunApiGetLotteryAwardList( "未鉴权用户获取奖品信息").request().validate().assert_equal( "body.code", 0)), Step( RunApiGetLotteryActivityInfo( "未鉴权用户获取活动主页信息").request().validate().assert_equal( "body.code", 0)), Step( RunApiGetLotteryPrizePeopleList( "未鉴权用户获取抽奖公告栏信息").request().validate().assert_equal( "body.code", 0)), Step( RunApiGetLotteryRecordList("未鉴权用户获取用户抽奖记录").with_variables( **{ "page_no": 1, "page_size": 20 }).request().validate().assert_startswith( "body.code", "-11000")), Step( RunApiGetActivityTaskList( "未鉴权用户获取任务信息").request().validate().assert_startswith( "body.code", "-11000")), Step( RunApiGetLotteryRemainingTimes( "未鉴权用户获取抽奖次数").request().validate().assert_startswith( "body.code", "-11000")), Step( RunApiEventCallback( "未鉴权用户调用事件回调接口").request().validate().assert_startswith( "body.code", "-11000")), ]
def register_login_new_users_impl(user_num=None) -> dict: """ Create users, register new users and log in. My own home id will be yield too. A dict will be returned, and keys are: - user_list """ user_list = [] client: Client = get_client_from_orm_by_id(1) for i in range(user_num): email = generate_email() password = "******" # register user register = TestRegisterNewUserSuccessfully() register.config.variables(**{ "client": client, "email": email, "password": password }) register.run() # login login = LoginV2() login.config.variables(**{ "client": client, "email": email, "password": password }) login.run() # {"account_id": ?, "token": ?} token_dict = get_sub_dict(login.get_export_variables(), *['account_id', 'token', 'user_info']) user_list.append(token_dict) yield user_list # delete user for token_dict in user_list: delete_user = DeleteUser() delete_user.with_variables( {} ) # get rid of the effect on session variables from previous instances delete_user.config.variables(client=client, **token_dict) delete_user.run()
def login_official_users_impl() -> dict: """ Login community official users. A dict will be returned, and keys are: - user_list """ user_list = [] client: Client = get_client_from_orm_by_id(1) community1_user_email = community_official_users_settings.community1_user_email community2_user_email = community_official_users_settings.community2_user_email password = "******" # login community_v1 official user login = LoginV2() login.config.variables(**{ "client": client, "email": community1_user_email, "password": password }) login.run() token_dict = get_sub_dict(login.get_export_variables(), *['account_id', 'token', 'user_info']) user_list.append(token_dict) # login community_v2 official user login = LoginV2() login.config.variables(**{ "client": client, "email": community2_user_email, "password": password }) login.run() token_dict = get_sub_dict(login.get_export_variables(), *['account_id', 'token']) user_list.append(token_dict) yield user_list
def register_login_new_users_and_complete_lottery_impl(user_num=2) -> dict: """ Create users, register new users and log in ,complete three times lottery. A dict will be returned, and keys are: - user_list """ user_list = [] expected_lottery_prize_people_list = [] client: Client = get_client_from_orm_by_id(1) for i in range(user_num): email = generate_email() password = "******" # register user register = TestRegisterNewUserSuccessfully() register.with_variables({ "client": client, "email": email, "password": password }) register.run() # login login = LoginV2() login.with_variables({ "client": client, "email": email, "password": password }) login.run() # {"account_id": ?, "token": ?} token_dict = get_sub_dict(login.get_export_variables(), *['account_id', 'token', 'user_info']) user_list.append(token_dict) # getRemainingTimes get_remaining_times = BaseGetRemainingTimesSuccessfully() get_remaining_times.with_variables({ **get_sub_dict(login.get_export_variables(), *[ 'account_id', 'token' ]), "client": client, "award_pool_name": anniversary_draw_settings.award_pool_name, "trigger_source": "$award_pool_name" }) get_remaining_times.run() # draw lottery draw = BaseDrawSuccessfully() draw.with_variables({ **get_sub_dict(login.get_export_variables(), *[ 'account_id', 'token', 'user_info' ]), "client": client, "award_pool_name": anniversary_draw_settings.award_pool_name, "trigger_source": "$award_pool_name", "expected_remaining_times": 0, "expected_lottery_prize_people_list": expected_lottery_prize_people_list }) draw.run() expected_lottery_prize_people_list = draw.get_export_variables( )['expected_lottery_prize_people_list'] yield { "user_list": user_list, "expected_lottery_prize_people_list": expected_lottery_prize_people_list } # delete user for token_dict in user_list: delete_user = DeleteUser() delete_user.with_variables( {} ) # get rid of the effect on session variables from previous instances delete_user.config.variables(client=client, **token_dict) delete_user.run()