def test_savings_recommend_product_with_all_sold_out( mock_get_order_amount_by_user, mock_get_total_orders, mock_has_bought_newcomer_product, client, oauth_token, oauth_client): headers = { 'X-Client-ID': oauth_client.client_id, 'X-Client-Secret': oauth_client.client_secret } client.load_token(oauth_token) # 买过新手标,随心攒售罄,365天售罄,环境准备 mock_get_order_amount_by_user.return_value = 1 mock_get_total_orders.return_value = 1 mock_has_bought_newcomer_product.return_value = True vendor = Vendor.get_by_name(Provider.sxb) sxb_products = SXBProduct.get_products_by_vendor_id(vendor.id_) for sxb in sxb_products: sxb.go_off_sale() # 访问路由,查找推荐产品 r = client.get(get_testurl_v2(testing_urls['recommend']), headers=headers) # 对比推荐产品,必须为随心攒 assert r.status_code == 200 assert r.data['success'] is True assert r.data['data']['wallet'] != [] wallet = r.data['data']['wallet'][0] vendor = Vendor.get_by_name(Provider.sxb) sxb_products = SXBProduct.get_products_by_vendor_id(vendor.id_) product_schema_assert(wallet, str(sxb_products[1].id_))
def sxb_product(sqlstore, redis, app): vendor = Vendor.get_by_name(Provider.sxb) if vendor is None: vendor = Vendor.add(Provider.sxb.value, 'sxb') product = Product.get_by_remote_id(vendor.id_, ProductConsts.SXB_VENDOR_PRODUCT_ID[0]) if product is None: def add_product(product_info): start_sell_date, end_sell_date = check_available_for_product( product_info) Product.add_or_update( vendor.id_, product_info.product_id, product_info.name, product_info.quota, product_info.total_quota, product_info.today_quota, product_info.total_amount, product_info.total_buy_amount, product_info.min_redeem_amount, product_info.max_redeem_amount, product_info.day_redeem_amount, product_info.add_year_rate, product_info.remark, Product.Type.unlimited, product_info.min_amount, product_info.max_amount, product_info.return_rate_type, product_info.return_rate, product_info.effect_day_type, product_info.effect_day, product_info.effect_day_unit, product_info.is_redeem, start_sell_date, end_sell_date) for i in range(len(ProductConsts.SXB_PRODUCT_INFO)): product_info = ProductConsts.SXB_PRODUCT_INFO[ ProductConsts.SXB_VENDOR_PRODUCT_ID[i]] add_product(Obj(product_info)) sxb_products = Product.get_products_by_vendor_id(vendor.id_) for p in sxb_products: if p.is_taken_down: p.go_on_sale() if p.remote_id == ProductConsts.SXB_VENDOR_PRODUCT_ID[0]: product = p return product
def update_to_hoarder_product(product): vendor_id = Vendor.get_by_name(Provider.xm).id_ Product.add_or_update( vendor_id, product.product_id, product.name, float(product.quota), float(product.total_amount), float(product.total_amount), float(product.total_amount), float(product.sold_amount), 0, 0, 0, 0, product.description, Product.Type.classic, product.min_amount, product.max_amount, # 固定收益率 1, product.annual_rate / 100, 1, 1, 1, Product.RedeemType.auto.value, product.start_sell_date, product.end_sell_date, product.expire_period, product.expire_period_unit)
def add_product(product): start_sell_date, end_sell_date = check_available_for_product( product) Product.add_or_update(vendor.id_, product.product_id, product.name, float(product.quota), float(product.total_amount), float(product.total_amount), float(product.total_amount), 0, 0, 0, 0, 0, product.remark, Product.Type.classic, product.min_amount, product.max_amount, 1, product.return_rate, 1, 1, 1, Product.RedeemType.auto.value, start_sell_date, end_sell_date, product.expire_period, product.expire_period_unit)
def add_product(product_info): start_sell_date, end_sell_date = check_available_for_product( product_info) Product.add_or_update( vendor.id_, product_info.product_id, product_info.name, product_info.quota, product_info.total_quota, product_info.today_quota, product_info.total_amount, product_info.total_buy_amount, product_info.min_redeem_amount, product_info.max_redeem_amount, product_info.day_redeem_amount, product_info.add_year_rate, product_info.remark, Product.Type.unlimited, product_info.min_amount, product_info.max_amount, product_info.return_rate_type, product_info.return_rate, product_info.effect_day_type, product_info.effect_day, product_info.effect_day_unit, product_info.is_redeem, start_sell_date, end_sell_date)
def xm_product(sqlstore, redis): vendor = Vendor.get_by_name(Provider.xm) if vendor is None: vendor = Vendor.add(Provider.xm.value, 'xm') product = XMProduct.get(ProductConsts.XINMI_PRODUCT_ID) if product is None: def add_product(product): start_sell_date, end_sell_date = check_available_for_product( product) Product.add_or_update(vendor.id_, product.product_id, product.name, float(product.quota), float(product.total_amount), float(product.total_amount), float(product.total_amount), 0, 0, 0, 0, 0, product.remark, Product.Type.classic, product.min_amount, product.max_amount, 1, product.return_rate, 1, 1, 1, Product.RedeemType.auto.value, start_sell_date, end_sell_date, product.expire_period, product.expire_period_unit) add_product(Obj(ProductConsts.XINMI_PRODUCT_INFO)) xm_products = Product.get_products_by_vendor_id(vendor.id_) for p in xm_products: if p.is_taken_down: p.go_on_sale() product = XMProduct.add(ProductConsts.XINMI_PRODUCT_INFO) return product
def init_product(self): self.init_vendor() vendor_id = Vendor.get_by_name(Provider.sxb).id_ remote_id = '2015122217504424733' name = '随心宝测试产品01' quota = 1000.0 total_quota = 200000.0 today_quota = 10000.0 total_amount = 3000000.0 total_buy_amount = 10000.0 min_redeem_amount = 1000.0 max_redeem_amount = 10000.0 day_redeem_amount = 1000.0 interest_rate_hike = 0.001 description = 'Test...' product_type = Product.Type.unlimited min_amount = 100 max_amount = 10000 rate_type = 3 rate = 0.083 effect_day_condition = 'C' effect_day = 1 effect_day_unit = '3' redeem_type = Product.RedeemType.user.value start_sell_date = datetime.today().date() end_sell_date = datetime.today().date() return Product.add_or_update(vendor_id, remote_id, name, quota, total_quota, today_quota, total_amount, total_buy_amount, min_redeem_amount, max_redeem_amount, day_redeem_amount, interest_rate_hike, description, product_type, min_amount, max_amount, rate_type, rate, effect_day_condition, effect_day, effect_day_unit, redeem_type, start_sell_date, end_sell_date)
def fillup_local(product_info, is_child_product=None): start_sell_date, end_sell_date = check_available_for_product(product_info) vendor_id = Vendor.get_by_name(Provider.sxb).id_ return Product.add_or_update(vendor_id, product_info.id_, product_info.name, product_info.quota, product_info.total_quota, product_info.today_quota, product_info.total_amount, product_info.total_buy_amount, product_info.min_redeem_amount, product_info.max_redeem_amount, product_info.day_redeem_amount, product_info.add_year_rate, product_info.remark, Product.Type.unlimited, product_info.min_amount, product_info.max_amount, product_info.return_rate_type.value, product_info.return_rate, product_info.effect_day_type.value, product_info.effect_day, product_info.effect_day_unit.value, product_info.is_redeem, start_sell_date, end_sell_date, is_child_product=is_child_product)
def test_savings_recommend_product_with_sold_out( mock_get_order_amount_by_user, mock_get_total_orders, mock_has_bought_newcomer_product, mock_check_is_inhouse, client, oauth_token, oauth_client, xm_product): headers = { 'X-Client-ID': oauth_client.client_id, 'X-Client-Secret': oauth_client.client_secret } client.load_token(oauth_token) # 买过新手标,随心攒售罄,环境准备 vendor = Vendor.get_by_name(Provider.sxb) sxb_products = SXBProduct.get_products_by_vendor_id(vendor.id_) for sxb in sxb_products: sxb.go_off_sale() mock_check_is_inhouse.return_value = True mock_get_order_amount_by_user.return_value = 1 mock_get_total_orders.return_value = 1 mock_has_bought_newcomer_product.return_value = True # 访问路由,查找推荐产品 r = client.get(get_testurl_v2(testing_urls['recommend']), headers=headers) # 对比推荐产品,必须为365天 assert r.status_code == 200 assert r.data['success'] is True assert r.data['data']['hoarder'] != [] hoarder = r.data['data']['hoarder'][0] product_schema_assert(hoarder, str(xm_product.product_id))
def purchase(json_data, g): """选购产品, 创建理财单.""" purchase_schema = PurchaseSchema(strict=True) response_schema = PurchaseResponseSchema() result = purchase_schema.load(json_data) product_id = result.data['product_id'] bankcard = obtain_bankcard(result.data['bankcard_id'], g) g.bankcard_manager.set_default(bankcard) amount = result.data.get('amount', 0) or 0 pocket_deduction_amount = result.data.get('pocket_deduction_amount', 0) or 0 coupon = obtain_coupon(result.data.get('coupon_id'), g.user) p = Product.get(product_id) if not p: raise OffShelfError() if amount < p.min_amount: raise OrderAmountTooSmallError(u'申购金额能少于{}元'.format( round_half_up(p.min_amount, 2))) order = sxb.subscribe_product(g.user, product_id, bankcard, amount, coupon, pocket_deduction_amount) inject_bankcard_amount_limit(Partner.xm, [order.bankcard]) order._display_status = order.status.display_text return response_schema.dump(order).data
def get_products(user=None): enabled_vendors = Vendor.get_enabled_vendors() matched_coupons = [] coupon_manager = None product_obj = { 'wallet': [], 'hoarder': [], 'help_url': url_for('activity.cake.index', _external=True) } if user: coupon_manager = CouponManager(user.id_) for vendor in enabled_vendors: products = [p for p in Product.get_products_by_vendor_id(vendor.id_)] for product in products: profile = COMMON_PRODUCT_PROFILE.get(vendor.provider) product.uid = product.id_ product.title = profile.get('title') product.activity_title = profile.get('activity_title') product.activity_introduction = profile.get( 'activity_introduction') product.annual_rate = product.rate * 100 product.tags = profile.get('tags') product.start_date = product.value_date rule_url = profile.get('withdraw_rule_url') product.withdraw_rule = url_for(rule_url, _external=True) if rule_url else '' if product.ptype is Product.Type.unlimited: product.annotations = {'has_coupons': False} product.period = profile.get('period') else: product.period = PERIODS.get(str(product.frozen_days)) if product.vendor.name == Provider.xm.value: product.uid = product.remote_id if coupon_manager: if product.vendor.name == Provider.xm.value: xm_product = XMFixedDuedayProduct.get( product.remote_id) matched_coupons = XMFixedDuedayProduct.get_product_annotations( coupon_manager, xm_product) product.annotations = {'has_coupons': len(matched_coupons) > 0} if product.is_sold_out: key = 'soldout' elif product.is_taken_down: key = 'offsale' elif product.is_pre_sale: key = 'presale' else: if product.ptype is Product.Type.unlimited: key = 'wallet_onsale' else: key = 'hoarder_onsale' product.display_status = PRODUCT_STATUS.get(key) if product.ptype is Product.Type.unlimited: product_obj['wallet'].append(product) else: product_obj['hoarder'].append(product) product_obj['wallet'].append(get_fund_product()) return product_obj
def test_add_or_update(self): self.init_product() vendor_id = Vendor.get_by_name(Provider.sxb).id_ remote_id = '2015122217504424733' name = '随心宝测试产品01' quota = 1000.0 total_quota = 200000.0 today_quota = 10000.0 total_amount = 3000000.0 total_buy_amount = 10000.0 min_redeem_amount = 1000.0 max_redeem_amount = 10000.0 day_redeem_amount = 1000.0 interest_rate_hike = 0.001 description = 'Test...' product_type = Product.Type.unlimited min_amount = 100 max_amount = 10000 rate_type = 3 rate = 0.083 effect_day_condition = 'C' effect_day = 1 effect_day_unit = '3' redeem_type = Product.RedeemType.user.value start_sell_date = datetime.today().date() end_sell_date = datetime.today().date() products = Product.get_products_by_vendor_id(vendor_id) assert len(products) > 0 assert products[0].vendor_id == int(vendor_id) assert products[0].quota == quota quota = Decimal('4000.0') updated_product = Product.add_or_update(vendor_id, remote_id, name, quota, total_quota, today_quota, total_amount, total_buy_amount, min_redeem_amount, max_redeem_amount, day_redeem_amount, interest_rate_hike, description, product_type, min_amount, max_amount, rate_type, rate, effect_day_condition, effect_day, effect_day_unit, redeem_type, start_sell_date, end_sell_date) assert updated_product.id_ == products[0].id_ assert updated_product.vendor_id == int(vendor_id) assert updated_product.quota == quota
def redeem(): """赎回资产 :request: :class:`.RedeemSchema` :reqheader Authorization: OAuth 2.0 Bearer Token :status 200: 赎回请求成功, 返回 :class:`.RedeemResponseSchema` :status 400: 产品或金额无效 :status 403: 第三方错误 """ redeem_schema = RedeemSchema(strict=True) result = redeem_schema.load(request.get_json(force=True)) product_id = result.data['product_id'] bankcard = obtain_bankcard(result.data['bankcard_id']) redeem_amount = result.data.get('redeem_amount') # 默认到期自动转移 和 加急 均为 否 is_express = result.data.get('is_express', False) is_expired = result.data.get('is_expired', False) product = Product.get(product_id) if not product: abort(400, u'产品无效') vendor = product.vendor if vendor and vendor.name == 'sxb': assets = Asset.gets_by_user_id_with_product_id(request.oauth.user.id_, product_id) if not assets: abort(400, u'用户没有可赎回资产') current_asset = assets[0] remaining_amount = (current_asset.uncollected_amount + current_asset.hold_amount - redeem_amount) # if remaining_amount != 0 and remaining_amount < 100: # abort(400, u'赎回金额无效: 赎回后余额小于100') try: redeem_order = sxb.redeem(request.oauth.user, product, redeem_amount, bankcard, is_expired, is_express) redeem_order.remaining_amount = remaining_amount redeem_order.bankcard_desc = '{0}({1})'.format( bankcard.bank_name, bankcard.tail_card_number) redeem_response_schema = RedeemResponseSchema(strict=True) data, errors = redeem_response_schema.dump(redeem_order) conditional_for(json.dumps(data)) return jsonify(success=True, data=data) except RedeemError as e: abort(403, unicode(e)) else: abort(400, '目前只支持随心宝产品赎回')
def sxb_withdraw(): vendor = Vendor.get_by_name(Provider.sxb) products = Product.get_products_by_vendor_id(vendor_id=vendor.id_) # 对随心宝产品默认取第一款上线产品为数据来源(只会上线一款随心宝产品) for p in products: if p.is_on_sale: break if not p: abort(403, u'产品已下线,请稍后再试') max_free_redeem_times = 5 total_buy_amount = p.total_buy_amount min_redeem_amount = p.min_redeem_amount day_redeem_amount = p.day_redeem_amount return render_template('wallet/sxb_withdraw_rule.html', **locals())
def index(): if g.user and HoardProfile.get(g.user.id_): return redirect(url_for('savings.mine.index')) amount = get_savings_amount() user_count = get_user_count() xm_products = XMFixedDuedayProduct.get_all() vendor = Vendor.get_by_name(Provider.sxb) sxb_products = Product.get_products_by_vendor_id(vendor.id_) return render_template('savings/index.html', amount=amount, user_count=user_count, xm_products=xm_products, sxb_products=sxb_products, cur_path='savings')
def sxb_purchase(): """选购产品, 创建理财单. :request: :class:`.PurchaseSchema` :reqheader Authorization: OAuth 2.0 Bearer Token :status 403: 因为未完成实名认证或第三方方面原因, 购买请求被拒 :status 400: 产品或金额无效, 其中产品无效可能是因为停售或售罄 :status 201: 订单已创建, 返回 :class:`.ProductSchema` """ # TODO: 需要增加服务器维护时间段。 purchase_schema = PurchaseSchema(strict=True) response_schema = PurchaseResponseSchema() result = purchase_schema.load(request.get_json(force=True)) product_id = result.data['product_id'] bankcard = obtain_bankcard(result.data['bankcard_id']) g.bankcard_manager.set_default(bankcard) amount = result.data.get('amount', 0) or 0 pocket_deduction_amount = result.data.get('pocket_deduction_amount', 0) or 0 coupon = obtain_coupon(result.data.get('coupon_id')) p = Product.get(product_id) if not p: abort(400, u'产品已下架') if amount < p.min_amount: abort(400, u'申购金额不能少于%s元' % round_half_up(p.min_amount, 2)) try: order = sxb.subscribe_product(request.oauth.user, product_id, bankcard, amount, coupon, pocket_deduction_amount) inject_bankcard_amount_limit(Partner.xm, [order.bankcard]) except NotFoundEntityError as e: warning('随心宝未找到相应实体', exception=e) abort(400, '未知错误') except (SubscribeProductError, UnboundAccountError) as e: abort(403, unicode(e)) except (CouponError, CouponUsageError) as e: abort(403, unicode(e)) except (SoldOutError, SuspendedError, OffShelfError, OutOfRangeError, InvalidIdentityError, ExceedBankAmountLimitError) as e: abort(403, unicode(e)) except FirewoodException: abort(403, u'红包出现错误,请稍后再试或联系客服') order._display_status = order.status.display_text return jsonify(success=True, data=response_schema.dump(order).data), 201
def pre_redeem(product_id): """赎回资产前获取用户相关的产品赎回信息 :reqheader Authorization: OAuth 2.0 Bearer Token :status 200: 请求成功, 返回 :class:`.PreRedeemResponseSchema` :status 400: 用户没有该产品的资产 :status 403: 找不到可赎回产品 """ assets = Asset.gets_by_user_id_with_product_id(request.oauth.user.id_, product_id) if not assets: abort(400, u'用户没有可赎回资产') current_asset = assets[0] product = Product.get(product_id) if not product: abort(403, u'找不到可赎回产品') bankcard = obtain_bankcard(current_asset.bankcard_id) current_asset.bankcard_desc = '{0}({1})'.format(bankcard.bank_name, bankcard.tail_card_number) current_asset.redeem_rule_url = url_for('hybrid.rules.sxb_withdraw', _external=True) current_asset._min_redeem_amount = product.min_redeem_amount current_asset._service_fee_rate = current_asset.service_fee_rate * 100 if current_asset.residual_redemption_times > 0: current_asset._service_fee_desc = u'本月还可免费提现 %s 次' % \ current_asset.residual_redemption_times else: current_asset._service_fee_desc = u'提现费率为 {}%'.format( round_half_up(current_asset.service_fee_rate * 100, 2)) pre_redeem_schema = PreRedeemResponseSchema(strict=True) data, errors = pre_redeem_schema.dump(current_asset) conditional_for(json.dumps(data)) return jsonify(success=True, data=data)
def mine(): # 攒钱助手 savings_manager = SavingsManager(g.user.id_) savings_products = ZhiwangProduct.get_all() vendor = Vendor.get_by_name(Provider.sxb) sxb_products = Product.get_products_by_vendor_id(vendor.id_) xm_products = XMFixedDuedayProduct.get_all() # 零钱包 wallet_dashboard = PublicDashboard.today() wallet_account = WalletAccount.get_by_local_account(g.user, zhongshan) if wallet_account: wallet_profile = UserDashboard.today(wallet_account) wallet_has_transaction = bool( WalletTransaction.get_ids_by_account(wallet_account.id_)) else: wallet_profile = None wallet_has_transaction = False # 规划书 report = Report.get_latest_by_plan_id(g.plan.id) if g.plan else None if not (report and report.status >= REPORT_STATUS.interdata): return render_template('/mine/center_unplanned.html', **locals()) if int(report.formula_ver) < int(FORMULA_VER): regen_log(report, 'start regenerate inter data') cal_intermediate_data(report, force=True, log=regen_log) report.update_formula_ver(FORMULA_VER) regen_log(report, 'success regenerate inter data FV:%s' % report.formula_ver) inter_data = report.inter_data locals().update(inter_data) cur_path = 'center' return render_template('/mine/center.html', **locals())
def test_savings_products_all(client, oauth_token, oauth_client, xm_product): headers = { 'X-Client-ID': oauth_client.client_id, 'X-Client-Secret': oauth_client.client_secret } r = client.get(get_testurl_v2(testing_urls['all']), headers=headers) assert r.status_code == 200 assert r.data['success'] is True assert r.data['data']['wallet'] != [] wallet = r.data['data']['wallet'] vendor = Vendor.get_by_name(Provider.sxb) sxb_products = SXBProduct.get_products_by_vendor_id(vendor.id_) for i in range(len(sxb_products)): product_schema_assert(wallet[i], str(sxb_products[i].id_)) fund = wallet[2] assert 'name' in fund assert 'title' in fund assert 'activity_title' in fund assert 'activity_introduction' in fund assert 'annual_rate' in fund assert 'tags' in fund assert 'display_status' in fund
def test_savings_recommend_product_with_old_user( mock_get_order_amount_by_user, mock_get_total_orders, mock_has_bought_newcomer_product, client, oauth_client, oauth_token): headers = { 'X-Client-ID': oauth_client.client_id, 'X-Client-Secret': oauth_client.client_secret } # 购买新手标 # 登录,访问路由,查找推荐产品 client.load_token(oauth_token) mock_get_order_amount_by_user.return_value = 1 mock_get_total_orders.return_value = 1 mock_has_bought_newcomer_product.return_value = True # 访问路由,查找推荐产品 r = client.get(get_testurl_v2(testing_urls['recommend']), headers=headers) # 对比推荐产品,必须为随心攒 assert r.status_code == 200 assert r.data['success'] is True assert r.data['data']['wallet'] != [] wallet = r.data['data']['wallet'][0] vendor = Vendor.get_by_name(Provider.sxb) sxb_products = SXBProduct.get_products_by_vendor_id(vendor.id_) assert 'withdraw_rule' in wallet product_schema_assert(wallet, str(sxb_products[1].id_))
def get_sxb_products(user_id): vendor = Vendor.get_by_name(Provider.sxb) vendor_product_profile = PRODUCT_PROFILE[vendor.provider] products = [ p for p in Product.get_products_by_vendor_id(vendor.id_) if p.kind is Product.Kind.father ] new_products = [ p for p in NewComerProduct.get_products_by_vendor_id(vendor.id_) if p.kind is Product.Kind.child ] products.extend(new_products) for product in products: if product.kind is Product.Kind.child: father_product = NewComerProduct.get_father_product_by_vendor_id( product.vendor.id_) product_id = father_product.id_ else: product_id = product.id_ assets = Asset.gets_by_user_id_with_product_id(user_id, product_id) product.rest_hold_amount = round_half_up(product.max_amount, 2) if assets: rest_hold_amount = product.max_amount - sum(asset.total_amount for asset in assets) product.rest_hold_amount = rest_hold_amount if rest_hold_amount > 0 else 0 product.remaining_amount_today = sum( [asset.remaining_amount_today for asset in assets]) if product.is_on_sale: product.button_display_text, product.button_click_text = ( sale_display_text['on_sale']) elif product.is_taken_down: product.button_display_text, product.button_click_text = ( sale_display_text['late_morning_off_sale'] if product.kind is Product.Kind.father else sale_display_text['middle_morning_off_sale']) elif product.is_sold_out: product.button_display_text, product.button_click_text = ( sale_display_text['late_morning_sold_out'] if product.kind is Product.Kind.father else sale_display_text['late_morning_sold_out']) if product.kind is Product.Kind.child: product.rest_hold_amount = 10000 product.max_amount = 10000 product.introduction = vendor_product_profile['new_comer'][ 'product_introduction'] product.title = vendor_product_profile['new_comer'][ 'product_title'] product.activity_title = vendor_product_profile['new_comer'][ 'activity_title'] product.activity_introduction = ( vendor_product_profile['new_comer']['activity_introduction']) product.annual_rate = product.operation_num * 100 else: product.introduction = vendor_product_profile['sxb'][ 'product_introduction'] product.title = vendor_product_profile['sxb']['product_title'] product.activity_title = vendor_product_profile['sxb'][ 'activity_title'] product.activity_introduction = vendor_product_profile['sxb'][ 'activity_introduction'] product.annual_rate = product.rate * 100 # is_either_sold_out, unique_product_id 为兼容老产品字段 product.is_either_sold_out = product.is_sold_out product.unique_product_id = product.remote_id product.is_able_purchased = product.is_on_sale product.check_benifit_date = product.value_date + timedelta(days=1) product.withdraw_rule = url_for('hybrid.rules.sxb_withdraw', _external=True) product.agreement = url_for('savings.landing.agreement_xinmi', _external=True) product._total_amount = 0 product.annotations = [] return products
def async_sxb_asset(): vendor = Vendor.get_by_name(Provider.sxb) product_ids = Product.get_product_ids_by_vendor_id(vendor_id=vendor.id_) for product_id in product_ids: for id_ in Asset.get_ids_by_product_id(product_id): hoarder_async_asset.produce(str(id_))
def test_get_product_ids_by_vendor_id(self): p = self.init_product() product_ids = Product.get_product_ids_by_vendor_id(p.vendor_id) assert len(product_ids) > 0 assert product_ids[0] == p.vendor_id