Exemple #1
0
def step_impl(context, webapp_user_name):
    expected = json.loads(context.text)
    actual = []

    #获取微众卡
    webapp_owner_id = context.webapp_owner_id
    user = User.objects.get(id=context.webapp_owner_id)
    openid = "%s_%s" % (webapp_user_name, user.username)
    url = '/workbench/jqm/preview/?module=market_tool:weizoom_card&model=weizoom_card_exchange_list&action=get&workspace_id=market_tool:weizoom_card&webapp_owner_id=%s&project_id=0&fmt=%s&opid=%s&is_wallet=1' % (
        webapp_owner_id, context.member.token, openid)
    url = bdd_util.nginx(url)
    response = context.client.get(url)
    while response.status_code == 302:
        print('[info] redirect by change fmt in shared_url')
        redirect_url = bdd_util.nginx(response['Location'])
        context.last_url = redirect_url
        response = context.client.get(bdd_util.nginx(redirect_url))
    if response.status_code == 200:
        cards = response.context['cards']['card']
        print('cards!!!!!!!!!!!!!!')
        print(cards)
        for card in cards:
            actual.append({'id': card['card_id']})
        actual.sort(key=lambda item: int(item['id']))
        bdd_util.assert_list(expected, actual)
    else:
        print('[info] redirect error,response.status_code :')
        print(response.status_code)
Exemple #2
0
def step_impl(context, user, news_title):
    materials_url = '/new_weixin/api/materials/'
    response = context.client.get(bdd_util.nginx(materials_url))
    newses_info = json.loads(response.content)['data']['items']

    for news_info in newses_info:
        if news_info['type'] == 'multi':
            if news_info['newses'][0]['title'] == news_title:
                multi_id = news_info['id']
                break
    multi_url = '/new_weixin/news_preview/?id=%s' % multi_id
    response = context.client.get(bdd_util.nginx(multi_url))
    actual_datas = json.loads(response.context['newses'])

    for actual_data in actual_datas:
        actual_data['content'] = actual_data.get('text', '')
        actual_data['cover'] = [{'url': actual_data.get('pic_url', '')}]
        actual_data['cover_in_the_text'] = actual_data.get('is_show_cover_pic')
        actual_data['jump_url'] = actual_data.get('url', '')
    expected_datas = json.loads(context.text)
    for expected_data in expected_datas:
        expected_data['cover_in_the_text'] = True if (expected_data.get(
            'cover_in_the_text', True) in ('true', 'yes', 'True', 'Yes',
                                           True)) else False
        if expected_data.get('jump_url', ''):
            expected_data[
                'jump_url'] = 'http://' + expected_data['jump_url'].strip()
    bdd_util.assert_list(expected_datas, actual_datas)
Exemple #3
0
def step_impl(context, webapp_user_name):
    url = '/workbench/jqm/preview/?module=market_tool:coupon&model=usage&action=get&workspace_id=market_tool:coupon&webapp_owner_id=%d&project_id=0&fmt=%s' % (
        context.webapp_owner_id, context.member.token)
    url = bdd_util.nginx(url)
    response = context.client.get(url)
    if response.status_code == 302:
        print('[info] redirect by change fmt in shared_url')
        redirect_url = bdd_util.nginx(response['Location'])
        response = context.client.get(bdd_util.nginx(redirect_url))
    else:
        print('[info] not redirect')
    coupons = response.context['coupons']
    actual = []
    for coupon in coupons:
        if coupon.status == 0:
            coupon.status = u'未使用'
            actual.append(coupon)
        else:
            coupon.status = u'unknown'

        coupon.money = coupon.money

    expected = json.loads(context.text)
    actual = __sort(actual)
    expected = __sort(expected)

    bdd_util.assert_list(expected, actual)
def step_impl(context, webapp_user_name, shared_webapp_user_name):
    webapp_owner_id = context.webapp_owner_id
    user = User.objects.get(id=webapp_owner_id)
    openid = "%s_%s" % (webapp_user_name, user.username)
    member = member_api.get_member_by_openid(openid, context.webapp_id)
    followed_member = Member.objects.get(
        username_hexstr=byte_to_hex(shared_webapp_user_name))
    if member:
        new_url = url_helper.remove_querystr_filed_from_request_path(
            context.shared_url, 'fmt')
        new_url = url_helper.remove_querystr_filed_from_request_path(
            new_url, 'opid')
        context.shared_url = "%s&fmt=%s" % (new_url, followed_member.token)
    response = context.client.get(context.shared_url)
    if response.status_code == 302:
        print('[info] redirect by change fmt in shared_url')
        redirect_url = bdd_util.nginx(response['Location'])
        context.last_url = redirect_url
        response = context.client.get(bdd_util.nginx(redirect_url))
    else:
        print('[info] not redirect')
        context.last_url = context.shared_url
    context.api_response = __get_red_packet_informations(
        context, webapp_owner_id, context.red_packet_rule_id, openid,
        context.page_owner_member_id).content
    print('context.api_response')
    print(context.api_response)
def __open_group(context, activity_id, fid, group_type, group_days,
                 group_price, product_id, openid):
    # 开团操作
    webapp_owner_id = context.webapp_owner_id
    params = {
        'webapp_owner_id': webapp_owner_id,
        'group_record_id': activity_id,
        'fid': fid,
        'group_type': group_type,
        'group_days': group_days,
        'group_price': group_price,
        'product_id': product_id
    }
    response = context.client.post(
        '/m/apps/group/api/group_participance/?_method=post', params)
    while response.status_code == 302:
        print('[info] redirect by change fmt in shared_url')
        redirect_url = bdd_util.nginx(response['Location'])
        context.last_url = redirect_url
        response = context.client.get(bdd_util.nginx(redirect_url))

    if json.loads(response.content)['code'] == 500:
        context.err_msg = json.loads(response.content)['errMsg']
        return response
    else:
        group_id = json.loads(response.content)['data']['relation_belong_to']
        context.put_order_info = {
            'woid': webapp_owner_id,
            'group_id': group_id,
            'product_ids': product_id,
            'activity_id': str(activity_id)
        }
        return response
def step_impl(context, webapp_user_name, shared_webapp_user_name, shared_url_name):
	shared_url = getattr(context, shared_url_name)
	response = context.client.get(shared_url)
	if response.status_code == 302:
		print('[info] redirect by change fmt in shared_url')
		redirect_url = bdd_util.nginx(response['Location'])
		context.last_url = redirect_url
		response = context.client.get(bdd_util.nginx(redirect_url))
	else:
		context.last_url = shared_url
def __api_get_group_list(context, webapp_owner_id, belong_to):
    #所有已开团购
    url = '/m/apps/group/api/m_group_list/?webapp_owner_id=%s&belong_to=%s' % (
        webapp_owner_id, belong_to)
    response = context.client.get(url)
    while response.status_code == 302:
        print('[info] redirect by change fmt in shared_url')
        redirect_url = bdd_util.nginx(response['Location'])
        context.last_url = redirect_url
        response = context.client.get(bdd_util.nginx(redirect_url))
    return response.content
def step_impl(context, webapp_user_name, title):
    user = User.objects.get(id=context.webapp_owner_id)
    openid = "%s_%s" % (webapp_user_name, user.username)
    red_envelope_rule_name = __get_red_envelope_rule_name(title)
    red_envelope_rule_id = __get_red_envelope_rule_id(red_envelope_rule_name)
    material_id = __get_material_id(title)
    url = '/workbench/jqm/preview/?module=market_tool:share_red_envelope&model=share_red_envelope&action=get&webapp_owner_id=%s&material_id=%s&red_envelope_rule_id=%s&fmt=%s&opid=%s' % (context.webapp_owner_id, material_id, red_envelope_rule_id, context.member.token,openid)
    url = bdd_util.nginx(url)
    context.red_envelope_url = url
    response = context.client.get(url)
    response = context.client.get(bdd_util.nginx(response['Location']))
def __get_into_group_list_pages(context, webapp_owner_id, openid):
    #进入全部团购活动列表页面
    url = '/m/apps/group/m_group_list/?webapp_owner_id=%s&fmt=%s&opid=%s' % (
        webapp_owner_id, context.member.token, openid)
    url = bdd_util.nginx(url)
    response = context.client.get(url)
    while response.status_code == 302:
        print('[info] redirect by change fmt in shared_url')
        redirect_url = bdd_util.nginx(response['Location'])
        context.last_url = redirect_url
        response = context.client.get(bdd_util.nginx(redirect_url))
    return response
Exemple #10
0
def step_impl(context, user):
    response = context.client.get(bdd_util.nginx(context.url))
    actual_count = json.loads(response.content)['data']['total_count']
    json_data = json.loads(context.text)
    expected_count = json_data[0]['result_quantity']
    #print('hellokittyassert',expected_count,':',actual_count)
    assert int(expected_count) == int(actual_count)
def step_impl(context, user):
    if hasattr(context, 'detail_url'):
        url = context.detail_url
    elif hasattr(context, 'realtime_messages_url'):
        url = context.realtime_messages_url
    else:
        url = '/new_weixin/api/realtime_messages/?filter_value=status:-1'
    response = context.client.get(bdd_util.nginx(url))
    realMsgs_data = json.loads(response.content)['data']['items']
    datas_text = json.loads(context.text)
    for data_text in datas_text:
        for realMsg_data in realMsgs_data:
            if hasattr(context, 'detail_url'):
                if data_text['inf_content'] == realMsg_data['text']:
                    message_id = realMsg_data['message_id']

            else:
                if data_text['member_name'] == realMsg_data[
                        'sender_username'].split('_')[0]:
                    message_id = realMsg_data['message_id']

                    break
        status = 0 if (data_text.get('star', True) in ('true', 'yes', 'True',
                                                       'Yes', True)) else 1
        url = '/new_weixin/api/message_collect/'
        response = context.client.post(url, {
            'message_id': message_id,
            'status': status
        })
def step_impl(context, user, member):
    member_id = bdd_util.get_member_by_username(member, context.webapp_id).id
    url = '/member/api/member_shipinfo/?id=' + str(member_id)
    expected = json.loads(context.text)
    response = context.client.get(bdd_util.nginx(url))
    items = json.loads(response.content)['data']['items']
    actual = []
    for record in items:
        # detail = record['coupon_detail'].split()[0]
        actual.append(
            dict(
                ship_name=record['ship_name'],
                ship_tel=record['ship_tel'],
                area=','.join(record['area'].split()),
                ship_address=record['ship_address'],
            ))
    # for ship_info in response.context['ship_infos']:
    #     ship = {}
    #     ship['area'] = regional_util.get_str_value_by_string_ids(ship_info.area)
    #     ship['area'] = ','.join(ship['area'].split())
    #     ship['ship_address'] = ship_info.ship_address
    #     ship['ship_name'] = ship_info.ship_name
    #     ship['ship_tel'] = ship_info.ship_tel
    #     actual.append(ship)
    bdd_util.assert_list(actual, expected)
Exemple #13
0
def step_impl(context, webapp_user_name, webapp_owner_name,lottery_name):
	lottery_id = __get_lottery_id(lottery_name)
	webapp_owner_id = context.webapp_owner_id
	url = '/m/apps/lottery/m_lottery/?webapp_owner_id=%s&id=%s' % (webapp_owner_id, lottery_id)
	url = bdd_util.nginx(url)
	context.shared_url = url
	print('context.shared_url:',context.shared_url)
Exemple #14
0
def step_impl(context, webapp_user_name, shared_webapp_user_name):
	webapp_owner_id = context.webapp_owner_id
	user = User.objects.get(id=webapp_owner_id)
	openid = "%s_%s" % (shared_webapp_user_name, user.username)
	member = module_api.get_member_by_openid(openid, context.webapp_id)
	if member:
		new_url = url_helper.remove_querystr_filed_from_request_path(context.shared_url, 'fmt')
		context.shared_url = "%s&fmt=%s" % (new_url, member.token)
	response = context.client.get(context.shared_url)
	if response.status_code == 302:
		redirect_url = bdd_util.nginx(response['Location'])
		context.last_url = redirect_url
		response = context.client.get(bdd_util.nginx(redirect_url))
	else:
		print('[info] not redirect')
		context.last_url = context.shared_url
def __get_red_packet_informations(context, webapp_owner_id, red_packet_rule_id,
                                  openid, fid):
    url = '/m/apps/red_packet/api/m_red_packet/?webapp_owner_id=%s&id=%s&fmt=%s&opid=%s&fid=%s' % (
        webapp_owner_id, red_packet_rule_id, context.member.token, openid, fid)
    url = bdd_util.nginx(url)
    response = context.client.get(url)
    while response.status_code == 302:
        print('[info] redirect by change fmt in shared_url')
        redirect_url = bdd_util.nginx(response['Location'])
        context.last_url = redirect_url
        response = context.client.get(bdd_util.nginx(redirect_url))
    if response.status_code == 200:
        return response
    else:
        print('[info] redirect error,response.status_code :')
        print(response.status_code)
def step_impl(context, webapp_user, product_name):
    product = bdd_util.get_product_by(product_name)
    expected = json.loads(context.text)
    url = "/m/apps/evaluate/m_more_evaluates/?webapp_owner_id={}&product_id={}".format(
        context.webapp_owner_id, product.id)

    response = context.client.get(bdd_util.nginx(url), follow=True)
    product_review_list = response.context['reviews']
    actual = []
    if product_review_list:
        for i in product_review_list:
            data = {}
            data['member'] = i['member_name']

            detail_list = []
            for detail in i['review_detail']:
                detail_list.append({
                    'title':
                    'name' if detail['title'] == u'姓名' else detail['title'],
                    'value':
                    detail['answer']
                })
            data['comments'] = detail_list

            data['picture_list'] = i['reviewed_product_pictures']
            actual.append(data)
    else:
        actual.append({})

    bdd_util.assert_list(expected, actual)
Exemple #17
0
def step_impl(context, user, webapp_user_name):
	if hasattr(context, 'client'):
		context.client.logout()
	context.client = bdd_util.login(user)
	client = context.client
	json_data = json.loads(context.text)
	openid = '%s_%s' % (webapp_user_name, user)
	member = __get_member_by_openid(openid)
	url = '/member/api/follow_relations/?member_id=%s' % member.id
	response = client.get(bdd_util.nginx(url))

	items = json.loads(response.content)['data']['items']
	actual_member_rellations = []
	for data_item in items:
		actual_member_rellation = {}
		actual_member_rellation['name'] = data_item['username']
		if str(data_item['source']) == '-1' or str(data_item['source']) == '0':
			actual_member_rellation['source'] = u'直接关注'
		elif str(data_item['source']) == '1':
			actual_member_rellation['source'] = u'推广扫码'
		else:
			actual_member_rellation['source'] = u'会员分享'

		if str(data_item['is_fans']) == '0':
			actual_member_rellation['is_fans'] = u'否'

		if str(data_item['is_fans']) == '1':
			actual_member_rellation['is_fans'] = u'是'

		actual_member_rellations.append(actual_member_rellation)
	bdd_util.assert_list(actual_member_rellations, json_data)

	context.click_member = None
	context.member_clicked = False
def step_impl(context, user, page_total, spreadPath):
    #spreadPath = spreadMethod(spreadPath)
    response = context.client.get(bdd_util.nginx(context.url))
    actual_total = int(
        json.loads(response.content)['data']['pageinfo']['max_page'])
    page_total = int(page_total)
    assert (page_total, actual_total)
Exemple #19
0
def step_impl(context, user):
    """
	@note context字段参考 webapp/modules/user_center/request_util.py 中的 get_user_info()
	"""
    print("login as user " + user)
    webapp_owner_id = context.webapp_owner_id
    print("webapp_owner_id: %d" % webapp_owner_id)
    url = '/termite/workbench/jqm/preview/?module=user_center&model=user_info&action=get&workspace_id=user_center&webapp_owner_id=%d' % (
        webapp_owner_id)
    print("url: " + url)
    response = context.client.get(bdd_util.nginx(url), follow=True)

    # member类型是<class 'modules.member.models.Member'>
    member = response.context['member']

    #context.user_center_stats = _get_stats_from_user_center_page(response.content)
    context.user_center_stats = {
        u'全部订单': member.history_order_count,
        u'待支付': member.not_payed_order_count,
        u'待发货': member.not_ship_order_count,
        u'待收货': member.shiped_order_count,
        u'购物车': member.shopping_cart_product_count,
    }
    # dumping
    for k, v in context.user_center_stats.items():
        print("'%s': %d" % (k, v))
Exemple #20
0
def step_get_presonal_review_list(context, webapp_user):
    expected = json.loads(context.text)
    url = "/workbench/jqm/preview/?woid=%d&module=mall&model=order_review_list&action=get" % context.webapp_owner_id
    response = context.client.get(bdd_util.nginx(url), follow=True)
    orders = response.context['orders']
    actual = []
    if orders:
        for order in orders:
            if not order.order_is_reviewed:
                data = {}
                data['order_no'] = order.order_id
                data['products'] = []
                for product in order.products:
                    p_data = {}
                    p_data['product_name'] = product.name
                    p_model_name = product.product_model_name
                    if p_model_name:
                        the_model_name = ""
                        for model in p_model_name:
                            the_model_name += model['property_value']
                        p_data['product_model_name'] = the_model_name
                    data['products'].append(p_data)
                actual.append(data)
    else:
        actual.append({})
    if not actual:
        actual.append({})
    bdd_util.assert_list(expected, actual)
def step_impl(context, webapp_usr_name, order_id):
    # 为获取完可顺利支付
    context.created_order_id = order_id

    url = '/workbench/jqm/preview/?woid=%s&module=mall&model=order&action=pay&order_id=%s' % (
        context.webapp_owner_id, order_id)
    response = context.client.get(bdd_util.nginx(url), follow=True)
    has_sub_order = response.context['has_sub_order']
    actual = response.context['order']
    actual.order_no = actual.order_id
    actual.order_time = (str(actual.created_at))
    actual.methods_of_payment = response.context['pay_interface']
    actual.member = actual.buyer_name
    actual.status = ORDERSTATUS2MOBILETEXT[actual.status]
    actual.ship_area = actual.area

    if has_sub_order:
        products = []
        orders = response.context['orders']
        for i, order in enumerate(orders):
            product_dict = {
                u"包裹" + str(i + 1): order.products,
                'status': ORDERSTATUS2MOBILETEXT[order.status]
            }
            products.append(product_dict)

        actual.products = products

    expected = json.loads(context.text)
    bdd_util.assert_dict(expected, actual)
Exemple #22
0
def step_impl(context, user, powerme_name):
    powerme_page_id, powerme_id = __powerme_name2id(powerme_name)  #纯数字
    url = '/apps/powerme/api/powerme_participances_export/?_method=get&export_id=%s' % (
        powerme_id)
    url = bdd_util.nginx(url)
    response = context.client.get(url)
    bdd_util.assert_api_call_success(response)
Exemple #23
0
def check_lottery_list(context, user, exlottery_name):
    design_mode = 0
    version = 1
    page = 1

    if hasattr(context, "enable_paginate"):
        enable_paginate = context.enable_paginate
    else:
        enable_paginate = 1
    if hasattr(context, "count_per_page"):
        count_per_page = context.count_per_page
    else:
        count_per_page = 10

    if hasattr(context, "paging"):
        paging_dic = context.paging
        count_per_page = paging_dic['count_per_page']
        page = paging_dic['page_num']

    lottery_page_id, exlottery_id = __exlottery_name2id(exlottery_name)  #纯数字
    url = '/apps/exlottery/api/exlottery_participances/?design_mode={}&version={}&id={}&count_per_page={}&page={}&enable_paginate={}&_method=get'.format(
        design_mode,
        version,
        exlottery_id,
        count_per_page,
        page,
        enable_paginate,
    )
    url = bdd_util.nginx(url)
    response = context.client.get(url)
    context.participances = json.loads(response.content)
    context.exlottery_id = "%s" % (exlottery_id)
Exemple #24
0
def step_impl(context, user, weapp_user):

    #获取消息详情的数据并处理
    response = context.client.get(bdd_util.nginx(context.detail_url))
    realMsgs_data = json.loads(response.content)['data']['items']
    actual_data = []
    for realMsg_data in realMsgs_data:
        adict = {}
        if realMsg_data['is_reply']:
            adict['member_name'] = realMsg_data['mp_username'] or user
        else:
            adict['member_name'] = realMsg_data['sender_username'].split(
                '_')[0]
        adict['inf_content'] = realMsg_data['text']
        if realMsg_data['is_news_type']:
            adict['inf_content'] = realMsg_data['news_title']
        adict['time'] = bdd_util.get_date_str(realMsg_data['created_at'][:10])
        #星标
        adict['star'] = realMsg_data['is_collected']
        adict['remark'] = realMsg_data['remark']
        actual_data.append(adict)
    expected_datas = json.loads(context.text)
    for expected_data in expected_datas:
        expected_data['time'] = bdd_util.get_date_str(expected_data['time'])
        if expected_data.get('star', ''):
            expected_data['star'] = True if (expected_data.get('star', True)
                                             in ('true', 'yes', 'True', 'Yes',
                                                 True)) else False
    bdd_util.assert_list(expected_datas, actual_data)
Exemple #25
0
def step_impl(context, user, weapp_user):
    #获取weapp_user的url
    realMsg_url = '/new_weixin/api/realtime_messages/?filter_value=status:-1'
    response = context.client.get(bdd_util.nginx(realMsg_url))
    realMsgs_data = json.loads(response.content)['data']['items']
    for realMsg_data in realMsgs_data:
        if realMsg_data['sender_username'].split('_')[0] == weapp_user:
            session_id = realMsg_data['session_id']
            reply = realMsg_data['could_replied']
            context.detail_url = '/new_weixin/api/realtime_messages_detail/?session_id=%s&replied=%s' % (
                session_id, reply)
            #访问详情网页,可以使unread值为1
            url = '/new_weixin/realtime_messages_detail/?session_id=%s&replied=%s' % (
                session_id, reply)
            context.client.get(bdd_util.nginx(url))
            break
Exemple #26
0
def step_impl(context, user):
    if hasattr(context, 'detail_url'):
        url = context.detail_url
    elif hasattr(context, 'realtime_messages_url'):
        url = context.realtime_messages_url
    else:
        url = '/new_weixin/api/realtime_messages/?filter_value=status:-1'
    response = context.client.get(bdd_util.nginx(url))
    realMsgs_data = json.loads(response.content)['data']['items']
    datas_text = json.loads(context.text)
    for data_text in datas_text:
        for realMsg_data in realMsgs_data:
            if hasattr(context, 'detail_url'):
                if data_text['inf_content'] == realMsg_data['text']:
                    message_id = realMsg_data['message_id']
                    session_id = realMsg_data['session_id']
                    break
            else:
                if data_text['member_name'] == realMsg_data[
                        'sender_username'].split('_')[0]:
                    message_id = realMsg_data['message_id']
                    session_id = realMsg_data['session_id']
                    break
        status = 1
        remark = data_text['remark']
        url = '/new_weixin/api/msg_memo/'
        response = context.client.post(
            url, {
                'message_id': message_id,
                'status': status,
                'session_id': session_id,
                'message_remark': remark
            })
Exemple #27
0
def step_impl(context, webapp_user_name, pay_type, pay_interface):
	if hasattr(context, 'product_ids'):
		product_ids = context.product_ids
		product_counts = context.product_counts
		product_model_names = context.product_model_names
		# 加默认地址
		context.webapp_user.update_ship_info(ship_name='11', ship_address='12', ship_tel='12345678970', area='1')
	else:
		# 获取购物车参数
		arugment = json.loads(context.text)
		product_ids, product_counts, product_model_names = _get_shopping_cart_parameters(context.webapp_user.id, arugment)

	if len(product_ids) == 1:
		url = '/workbench/jqm/preview/?woid=%s&module=mall&model=order&action=edit&product_id=%s&product_count=%s&product_model_name=%s' % (context.webapp_owner_id, product_ids[0], product_counts[0], product_model_names[0])
	else:
		url = '/workbench/jqm/preview/?woid=%s&module=mall&model=shopping_cart_order&action=edit&product_ids=%s&product_counts=%s&product_model_names=%s' % (context.webapp_owner_id, product_ids, product_counts, product_model_names)

	response = context.client.get(bdd_util.nginx(url), follow=True)

	pay_interface_names = [p.get_str_name() for p in response.context['order'].pay_interfaces]
	# print(pay_interface_names)
	# print(pay_type)

	if pay_type == u'能':
		if pay_interface == u"微众卡支付":
			from market_tools.tools.weizoom_card.models import AccountHasWeizoomCardPermissions
			context.tc.assertTrue(AccountHasWeizoomCardPermissions.is_can_use_weizoom_card_by_owner_id(context.webapp_owner_id))
		else:
			context.tc.assertTrue(pay_interface in pay_interface_names)
	else:
		context.tc.assertTrue(pay_interface not in pay_interface_names)
Exemple #28
0
def _get_product_model_name_from_ids(webapp_owner_id, ids):
	if ids is None or ids == "standard":
		return "standard"
	return get_custom_model_id_from_name(webapp_owner_id ,ids)

# jz 2015-09-02
# @then(u"{webapp_user_name}成功创建订单")
# def step_impl(context, webapp_user_name):
# 	order_id = context.created_order_id
# 	if order_id == -1:
# 		print('Server Error: ', json.dumps(json.loads(context.response.content), indent=True))
# 		assert False, "order_id must NOT be -1"
# 		return
# @then(u"{webapp_user_name}成功创建订单")
# def step_impl(context, webapp_user_name):
# 	order_id = context.created_order_id
# 	if order_id == -1:
# 		print('Server Error: ', json.dumps(json.loads(context.response.content), indent=True))
# 		assert False, "order_id must NOT be -1"
# 		return
#
# 	order = Order.objects.get(order_id=order_id)
#
# 	url = '/workbench/jqm/preview/?woid=%s&module=mall&model=order&action=pay&order_id=%s' % (context.webapp_owner_id, order_id)
# 	response = context.client.get(bdd_util.nginx(url), follow=True)
# 	actual_order = response.context['order']
# 	actual_order.ship_area = actual_order.area
# 	actual_order.status = ORDERSTATUS2TEXT[actual_order.status]
# 	#获取coupon规则名
# 	if (actual_order.coupon_id != 0) and (actual_order.coupon_id != -1):
# 		coupon = Coupon.objects.get(id=actual_order.coupon_id)
# 		actual_order.coupon_id = coupon.coupon_rule.name
#
# 	for product in actual_order.products:
# 		# print('---product---', product)
# 		if 'custom_model_properties' in product and product['custom_model_properties']:
# 			product['model'] = ' '.join([property['property_value'] for property in product['custom_model_properties']])
#
# 	# print('---actual_order---', actual_order)
# 	expected = json.loads(context.text)
# 	bdd_util.assert_dict(expected, actual_order)
	url = '/workbench/jqm/preview/?woid=%s&module=mall&model=order&action=pay&order_id=%s' % (context.webapp_owner_id, order_id)
	response = context.client.get(bdd_util.nginx(url), follow=True)
	actual_order = response.context['order']
	actual_order.ship_area = actual_order.area
	actual_order.status = ORDERSTATUS2TEXT[actual_order.status]
	#获取coupon规则名
	if (actual_order.coupon_id != 0) and (actual_order.coupon_id != -1):
		coupon = Coupon.objects.get(id=actual_order.coupon_id)
		actual_order.coupon_id = coupon.coupon_rule.name

	for product in actual_order.products:
		# print('---product---', product)
		if 'custom_model_properties' in product and product['custom_model_properties']:
			product['model'] = ' '.join([property['property_value'] for property in product['custom_model_properties']])

	# print('---actual_order---', actual_order)
	expected = json.loads(context.text)
	bdd_util.assert_dict(expected, actual_order)
def step_impl(context, webapp_user_name):
	url = '/workbench/jqm/preview/?woid=%s&module=mall&model=pay_interfaces&action=list&order_id=0&ignore_template=1' % context.webapp_owner_id
	response = context.client.get(bdd_util.nginx(url), follow=True)
	pay_interfaces = response.context['pay_interfaces']

	expected = json.loads(context.text)
	actual = [pay_interface.name for pay_interface in pay_interfaces]
	bdd_util.assert_list(expected, actual)
Exemple #30
0
def step_impl(context, user, powerme_name):
    powerme_page_id, powerme_id = __powerme_name2id(powerme_name)  #纯数字
    url = '/apps/powerme/api/powerme_participances/?_method=get&id=%s' % (
        powerme_id)
    url = bdd_util.nginx(url)
    response = context.client.get(url)
    context.participances = json.loads(response.content)
    context.powerme_id = "%s" % (powerme_id)