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

	bdd_util.assert_api_call_success(resp)
	bdd_util.assert_list(expected, actual)
示例#2
0
def step_impl(context, user):
	expected = json.loads(context.text)
	resp = context.client.get("ginger-order:mall.ship_infos")
	actual = resp.data["ship_infos"]

	bdd_util.assert_api_call_success(resp)
	bdd_util.assert_list(expected, actual)
示例#3
0
def step_impl(context, corp_user):
	resp = context.client.get('ginger-crm:customer.customers', {})
	bdd_util.assert_api_call_success(resp)
	actual = resp.data['customers']

	expected = json.loads(context.text)
	bdd_util.assert_list(expected, actual)
示例#4
0
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)
示例#5
0
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)
示例#6
0
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)
示例#7
0
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-product:product.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)
示例#8
0
def step_impl(context, user):
    expected = json.loads(context.text)
    resp = context.client.get("ginger-product: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)
示例#9
0
def step_impl(context, corp_user):
    resp = context.client.get('ginger-promotion:point.products', {})
    bdd_util.assert_api_call_success(resp)
    actual = resp.data['products']

    for item in actual:
        item['name'] = item['product']['name']
        item['point_price'] = round(item['point_price'] / 100.0, 2)
        item['money_price'] = round(item['money_price'] / 100.0, 2)
        item['start_time'] = item['start_time'].split(' ')[0]
        item['end_time'] = item['end_time'].split(' ')[0]

    expected = json.loads(context.text)
    for item in expected:
        if 'start_time' in item:
            item['start_time'] = bdd_util.get_date(
                item['start_time']).strftime("%Y-%m-%d")
        if 'end_time' in item:
            item['end_time'] = bdd_util.get_date(
                item['end_time']).strftime("%Y-%m-%d")

    bdd_util.assert_list(expected, actual)