def step_impl(context, user):
    expected = json.loads(context.text)
    resp = context.client.get("product.labels")
    actual = resp.data["labels"]

    bdd_util.assert_api_call_success(resp)
    bdd_util.assert_list(expected, actual)
def step_impl(context, user, label_name):
    label_id = product_label_steps.get_product_label_id_by_name(label_name)
    actual = __get_products(context, user, u'标签', {'label_id': label_id})

    expected = json.loads(context.text)

    bdd_util.assert_list(expected, actual)
def step_impl(context, user, category_name):
    category_id = get_product_category_id_by_name(category_name)
    actual = __get_products(context, user, u'分类', {'category_id': category_id})

    expected = json.loads(context.text)

    bdd_util.assert_list(expected, actual)
def step_impl(context, user, type_name):
    actual = __get_products(context, user, type_name)
    #context.products = actual

    if context.table:
        expected = []
        for product in context.table:
            product = dict(product.as_dict())
            if 'barCode' in product:
                product['bar_code'] = product['barCode']
                del product['barCode']

            if 'categories' in product:
                product['categories'] = product['categories'].split(',')
                # 处理空字符串分割问题
                if product['categories'][0] == '':
                    product['categories'] = []
            # 处理table中没有验证库存的行
            if 'stocks' in product and product['stocks'] == '':
                del product['stocks']
            # 处理table中没有验证条码的行
            if 'bar_code' in product and product['bar_code'] == '':
                del product['bar_code']

            expected.append(product)
    else:
        print 'load expected from context.text'
        expected = json.loads(context.text)

    bdd_util.assert_list(expected, actual)
Beispiel #5
0
def step_impl(context, user):
	expected = json.loads(context.text)
	resp = context.client.get("product.corp_product_properties")
	bdd_util.assert_api_call_success(resp)

	actual = resp.data["product_properties"]
	for property_item in actual:
		for value_item in property_item['values']:
			value_item['image'] = value_item['image']
			value_item['name'] = value_item['text']

	bdd_util.assert_list(expected, actual)
def step_impl(context, user, category_name):
    expected = json.loads(context.text)
    father_id = get_product_category_id_by_name(
        category_name) if category_name != u'一级' else 0
    resp = context.client.get("ginger-mall:mall.sub_categories",
                              {"father_id": father_id})
    actual = [
        category for category in resp.data["categories"]
        if category['is_enabled']
    ]

    bdd_util.assert_api_call_success(resp)
    bdd_util.assert_list(expected, actual)