def __get_into_shvote_signup_pages(context): #进入高级微信投票-- 报名,填写个人资料页面 webapp_owner_id = context.webapp_owner_id shvote_id = context.shvote_id url = '/m/apps/shvote/shvote_participance/?webapp_owner_id=%s&id=%s&opid=%s' % ( webapp_owner_id, shvote_id, context.openid) #模拟获取填写资料页面 apps_util.get_response(context, url) text = json.loads(context.text) termite_post_args = { 'webapp_owner_id': webapp_owner_id, 'belong_to': shvote_id, 'icon': text.get('icon'), 'name': text.get('name', ''), 'group': text.get('group', ""), 'serial_number': text.get('serial_number'), 'details': text.get('details', ''), 'pics': json.dumps(text.get('pics')) } return apps_util.get_response( context, { "app": "m/apps/shvote", "resource": "shvote_participance", "type": "api", "method": "put", "args": termite_post_args })
def step_impl(context, webapp_user_name, group): #获取页面 apps_util.get_response(context, { "app": "m/apps/shvote", "resource": "m_shvote_rank", "method": "get", "args": { "webapp_owner_id": context.webapp_owner_id, "id": context.shvote_id } }) #获取排行数据 response = __get_rank_data(context, group) expected_data = json.loads(context.text) result_data = json.loads(response.content)['data']['result_list'] expected_keys = actual_data = [] if len(expected_data) > 0: expected_keys = expected_data[0].keys() for data in result_data: expected_keys = expected_keys if expected_keys else data.keys() tmp_dict = {} for k, v in data.items(): if k in expected_keys: tmp_dict[k] = v actual_data.append(tmp_dict) apps_util.debug_print(expected_data) apps_util.debug_print(actual_data) bdd_util.assert_list(expected_data,actual_data)
def step_impl(context, webapp_user_name, verify_code_bdd): #先生成验证码 app_utils.get_response( context, { "app": "m/apps/exlottery", "resource": "m_captcha", "method": "get", "type": "api", "args": { "webapp_owner_id": context.webapp_owner_id } }) #人工修改验证码 context.verify_code_for_bdd = verify_code_bdd
def step_impl(context, webapp_user_name, target_user_name): record_id = context.shvote_id shp = shvote_models.ShvoteParticipance.objects.get( belong_to=record_id, name=target_user_name, is_use=shvote_models.MEMBER_IS_USE['YES']) app_utils.get_response( context, { "app": "m/apps/shvote", "resource": "shvote_participance", "method": "post", "type": "api", "args": { "webapp_owner_id": context.webapp_owner_id, "recordId": record_id, "vote_to": shp.id, "voted_group": shp.group } })
def get_dynamic_data(context): return apps_util.get_response(context, { "app": "m/apps/shvote", "resource": "m_shvote", "type": "api", "method": "get", "args": { "webapp_owner_id": context.webapp_owner_id, "recordId": context.shvote_id } })
def get_dynamic_data(context): return apps_util.get_response(context, { "app": "m/apps/exsign", "resource": "m_exsign", "type": "api", "method": "get", "args": { "webapp_owner_id": context.webapp_owner_id, "id": context.exsign_id } })
def __get_rank_data(context, group): return apps_util.get_response(context, { "app": "m/apps/shvote", "resource": "m_shvote_rank", "method": "get", "type": "api", "args": { "webapp_owner_id": context.webapp_owner_id, "recordId": context.shvote_id, "current_group": group, "search_name": context.search if hasattr(context, 'search') else "" } })
def __Stop_Shvote(context,shvote_id): """ 关闭高级投票活动 """ return app_utils.get_response(context, { "app": "apps/shvote", "resource": "shvote_status", "method": "post", "type": "api", "args": { "id":shvote_id, "target":'stoped', "is_test": True } })
def __get_into_lottery_pages(context, webapp_owner_id, lottery_id, lottery_code): #进入专项抽奖活动页面 response = app_utils.get_response( context, { "app": "m/apps/exlottery", "resource": "m_exlottery", "method": "get", "args": { "webapp_owner_id": webapp_owner_id, "ex_code": lottery_code, "id": lottery_id } }) return response
def view_mobile_main_page(context): """ 进入活动主页 @param context: @return: """ return apps_util.get_response(context, { "app": "m/apps/shvote", "resource": "m_shvote", "method": "get", "type": "get", "args": { "webapp_owner_id": context.webapp_owner_id, "id": context.shvote_id } })
def __Delete_Shvote(context,shvote_id): """ 删除高级投票活动 注释:page表在原后台,没有被删除 """ return app_utils.get_response(context, { "app": "apps/shvote", "resource": "shvote", "method": "delete", "type": "api", "args": { "id": shvote_id } })
def __get_into_exlottery_home_page(context): """ 进入抽奖主页 @param context: @return: """ return app_utils.get_response( context, { "app": "m/apps/exlottery", "resource": "m_exlottery_page", "method": "get", "args": { "webapp_owner_id": context.webapp_owner_id, "id": context.exlottery_id } })
def step_impl(context, webapp_user_name, lottery_name): context.exlottery_detail = { 'webapp_owner_id': context.webapp_owner_id, 'id': context.exlottery_id, 'ex_code': context.exlottery_code } response = app_utils.get_response( context, { "app": "m/apps/exlottery", "resource": "exlottery_prize", "method": "put", "type": "api", "args": context.exlottery_detail }) context.lottery_result = json.loads(response.content)
def step_impl(context, webapp_user_name_new, webapp_user_name, lottery_name): user = User.objects.get(id=context.webapp_owner_id) openid = "%s_%s" % (webapp_user_name_new, user.username) context.openid = openid response = app_utils.get_response( context, { "app": "m/apps/exlottery", "resource": "exlottery_prize", "method": "put", "type": "api", "args": { 'webapp_owner_id': context.webapp_owner_id, 'id': context.exlottery_id, 'code': context.exlottery_code } }) context.errMsg = json.loads(response.content)['errMsg']
def step_impl(context, webapp_user_name, lottery_time, lottery_name): exlottery_time = bdd_util.get_datetime_str(lottery_time) context.exlottery_detail = { 'webapp_owner_id': context.webapp_owner_id, 'id': context.exlottery_id, 'ex_code': context.exlottery_code } response = app_utils.get_response( context, { "app": "m/apps/exlottery", "resource": "exlottery_prize", "method": "put", "type": "api", "args": context.exlottery_detail }) context.lottery_result = json.loads(response.content) ExlottoryRecord.objects(code=context.exlottery_code).update( created_at=exlottery_time)
def step_impl(context, webapp_user_name): user = User.objects.get(id=context.webapp_owner_id) openid = "%s_%s" % (webapp_user_name, user.username) context.openid = openid response = app_utils.get_response( context, { "app": "m/apps/exlottery", "resource": "m_exlottery_page", "method": "get", "type": "api", "args": { "webapp_owner_id": context.webapp_owner_id, "id": context.exlottery_id, "excode": context.exlottery_code, "verify_code": context.verify_code, "verify_code_for_bdd": context.verify_code_for_bdd, "tel": context.tel } }) context.errMsg = json.loads(response.content)['errMsg']