Пример #1
0
def step_impl(context, user, display_name):
    infos = json.loads(context.text)

    response = context.client.get('/config/api/get_all_unsynced_self_shops/',
                                  {})
    content = json.loads(response.content)

    storename2id = {}
    for weapp_user in content["data"]["rows"]:
        storename2id[weapp_user["text"]] = weapp_user["value"]

    for info in infos:
        if info.get("zy_account",
                    None) and info["zy_account"] in storename2id.keys():
            woid = storename2id[info["zy_account"]]
        else:
            woid = 0

        params = {
            'id': __get_user_id_by_display_name(display_name),
            'name': info.get('account_name', ''),
            'password': info.get('password', ''),
            'display_name': info.get('account_main', ''),
            'status': __get_status(info.get('isopen', '')),
            'woid': woid  #TODO 自营平台woid暂时存0
        }
        response = context.client.post('/config/api/user/', params)
        bdd_util.assert_api_call_success(response)
Пример #2
0
def step_impl(context):
    users = json.loads(context.text)
    for user in users:
        user['password'] = '******'
        if not 'thumbnail' in user:
            user['thumbnail'] = '/static/img/default_user.jpg'
        response = context.client.put('/account/api/user/', user)
        bdd_util.assert_api_call_success(response)
Пример #3
0
def step_impl(context, user):
    infos = json.loads(context.text)
    for info in infos:
        params = {
            'id': __get_user_id_by_username(info.get('account_name', ''))
        }
        response = context.client.post('/config/api/users/', params)
        bdd_util.assert_api_call_success(response)
def step_impl(context, user):
    context.infos = json.loads(context.text)
    for info in context.infos:
        account_main = info.get('account_main', '')
        user_id = User.objects.get(first_name=account_main).id
        customer_id = customer_models.CustomerMessage.objects.get(
            user_id=user_id).id
        params = {'id': customer_id, 'method': 'close'}
        response = context.client.post('/application_audit/api/applications/',
                                       params)
        bdd_util.assert_api_call_success(response)
def step_impl(context, user):
	products = json.loads(context.text)
	for product in products:
		weapps = product['weapp_id']
		if weapps:
			product_name = product['name']
			product = product_models.Product.objects.get(product_name=product_name)
			product_info = {
				'product_id': product.id,
				'weapps': json.dumps(weapps)
			}
			response = context.client.put('/product/api/relation_step/', product_info)
			bdd_util.assert_api_call_success(response)
def step_impl(context, user):
    infos = json.loads(context.text)
    for info in infos:
        params = {
            'account_type': __get_type(info.get('account_type', '')),
            'name': info.get('account_name', ''),
            'username': info.get('login_account', ''),
            'password': info.get('password', ''),
            'note': info.get('ramarks', '')
        }
        response = context.client.put('/manager/api/account_create/', params)
        print(response)
        bdd_util.assert_api_call_success(response)
Пример #7
0
def step_impl(context, user):
	products = json.loads(context.text)
	for product in products:
		stock_value = PRODUCT_STORE_TEXT2VALUE[product['stock_type']]
		product_info = {
			'product_name': product['name'],
			'promotion_title': product['promotion_name'],
			'product_price': product['price'],
			'clear_price': product['settlement_price'],
			'product_weight': product['weight'],
			'product_store': stock_value,
			'remark': product['introduction']
		}
		response = context.client.put('/product/api/new_product/', product_info)
		bdd_util.assert_api_call_success(response)
Пример #8
0
def step_impl(context, user, product_name):
	user_id = bdd_util.get_user_id_for(user)
	edit_product = product_models.Product.objects.get(owner_id=user_id, product_name=product_name)
	product_id = edit_product.id
	products = json.loads(context.text)
	for product in products:
		stock_value = PRODUCT_STORE_TEXT2VALUE[product['stock_type']]
		product_info = {
			'id': product_id,
			'product_name': product['name'],
			'promotion_title': product['promotion_name'],
			'product_price': product['price'],
			'clear_price': product['settlement_price'],
			'product_weight': product['weight'],
			'product_store': stock_value,
			'remark': product['introduction']
		}
		response = context.client.post('/product/api/new_product/', product_info)
		bdd_util.assert_api_call_success(response)
Пример #9
0
def step_impl(context, user, product_name):
	user_id = bdd_util.get_user_id_for(user)
	product = product_models.Product.objects.get(owner_id=user_id, product_name=product_name)
	response = context.client.delete('/product/api/new_product/', {'id': product.id})
	bdd_util.assert_api_call_success(response)
Пример #10
0
def step_impl(context, user_name):
    user = auth_models.User.objects.get(username=user_name)

    response = context.client.delete('/account/api/user/', {'id': user.id})
    bdd_util.assert_api_call_success(response)