@pytest.mark.django_db
def test_cross_sell_plugin_type():
 shop = get_default_shop()
 supplier = get_default_supplier()
 product = create_product('test-sku', shop=shop, supplier=supplier, stock_behavior=StockBehavior.UNSTOCKED)
 context = get_jinja_context(product=product)
 type_counts = ((ProductCrossSellType.RELATED, 1), (ProductCrossSellType.RECOMMENDED, 2), (ProductCrossSellType.BOUGHT_WITH, 3))
 for (type, count) in type_counts:
  _create_cross_sell_products(product, shop, supplier, type, count)
  assert (ProductCrossSell.objects.filter(product1=product, type=type).count() == count)
 for (type, count) in type_counts:
  assert (len(list(product_helpers.get_product_cross_sells(context, product, type, count))) == count)

@ pytest . mark . django_db def test_cross_sell_plugin_type ( ) : shop = get_default_shop ( ) supplier = get_default_supplier ( ) product = create_product ( 'test-sku' , shop = shop , supplier = supplier , stock_behavior = StockBehavior . UNSTOCKED ) context = get_jinja_context ( product = product ) type_counts = ( ( ProductCrossSellType . RELATED , 1 ) , ( ProductCrossSellType . RECOMMENDED , 2 ) , ( ProductCrossSellType . BOUGHT_WITH , 3 ) ) for ( type , count ) in type_counts : _create_cross_sell_products ( product , shop , supplier , type , count ) assert ( ProductCrossSell . objects . filter ( product1 = product , type = type ) . count ( ) == count ) for ( type , count ) in type_counts : assert ( len ( list ( product_helpers . get_product_cross_sells ( context , product , type , count ) ) ) == count )
test that template helper returns correct number of cross sells when shop contains multiple relation types .