Пример #1
0
def test_price_infos_are_discounted(rf):
    request = initialize_test(rf, True)

    price = request.shop.create_price

    product_one = create_product("Product_1", request.shop, default_price=150)
    product_two = create_product("Product_2", request.shop, default_price=250)

    spp = DiscountedProductPrice(product=product_one, shop=request.shop, price_value=100)
    spp.save()

    spp = DiscountedProductPrice(product=product_two, shop=request.shop, price_value=200)
    spp.save()

    product_ids = [product_one.pk, product_two.pk]

    dpm = DiscountPricingModule()
    pricing_context = dpm.get_context_from_request(request)
    price_infos = dpm.get_price_infos(pricing_context, product_ids)

    assert len(price_infos) == 2
    assert product_one.pk in price_infos
    assert product_two.pk in price_infos

    first_price_info = price_infos[product_one.pk]
    second_price_info = price_infos[product_two.pk]

    assert first_price_info.price == price(100)
    assert first_price_info.base_price == price(150)
    assert first_price_info.is_discounted

    assert second_price_info.price == price(200)
    assert second_price_info.base_price == price(250)
    assert second_price_info.is_discounted
Пример #2
0
def test_set_taxful_price_works_with_product_id(rf):
    request = initialize_test(rf, True)
    price = request.shop.create_price

    product = create_product("Anuva-Product", request.shop, default_price=300)

    # create ssp with higher price
    spp = DiscountedProductPrice(product=product, shop=request.shop, price_value=250)
    spp.save()

    price_info = product.get_price_info(request, quantity=1)

    assert price_info.price == price(250)

    assert product.get_price(request, quantity=1) == price(250)
Пример #3
0
def test_set_taxful_price_works_with_product_id(rf):
    request = initialize_test(rf, True)
    price = request.shop.create_price

    product = create_product("Anuva-Product", request.shop, default_price=300)

    # create ssp with higher price
    spp = DiscountedProductPrice(product=product, shop=request.shop, price_value=250)
    spp.save()

    dpm = DiscountPricingModule()
    pricing_context = dpm.get_context_from_request(request)
    price_info = dpm.get_price_info(pricing_context, product=product.pk, quantity=1)

    assert price_info.price == request.shop.create_price(250)

    assert product.get_price(pricing_context, quantity=1) == price(250)
Пример #4
0
def test_set_taxful_price_works(rf):
    request = initialize_test(rf, True)
    price = request.shop.create_price

    product = create_product("Anuva-Product", request.shop, default_price=300)

    # create ssp with higher price
    spp = DiscountedProductPrice(product=product,
                                 shop=request.shop,
                                 price_value=250)
    spp.save()

    price_info = product.get_price_info(request, quantity=1)

    assert price_info.price == price(250)

    assert product.get_price(request, quantity=1) == price(250)
Пример #5
0
def test_set_taxful_price_works_with_product_id(rf):
    request = initialize_test(rf, True)

    product = create_product("Anuva-Product", request.shop, default_price=300)

    # create ssp with higher price
    spp = DiscountedProductPrice(product=product, shop=request.shop, price=250)
    spp.save()

    dpm = DiscountPricingModule()
    pricing_context = dpm.get_context_from_request(request)
    price_info = dpm.get_price_info(pricing_context, product=product.pk, quantity=1)

    assert price_info.price == TaxfulPrice(250)

    pp = product.get_price(pricing_context, quantity=1)

    assert pp == TaxfulPrice("250")
Пример #6
0
def test_price_infos_are_discounted(rf):
    request = initialize_test(rf, True)

    price = request.shop.create_price

    product_one = create_product("Product_1", request.shop, default_price=150)
    product_two = create_product("Product_2", request.shop, default_price=250)

    spp = DiscountedProductPrice(product=product_one, shop=request.shop, price_value=100)
    spp.save()

    spp = DiscountedProductPrice(product=product_two, shop=request.shop, price_value=200)
    spp.save()

    product_ids = [product_one.pk, product_two.pk]

    dpm = get_pricing_module()
    pricing_context = dpm.get_context_from_request(request)
    price_infos = dpm.get_price_infos(pricing_context, product_ids)

    assert len(price_infos) == 2
    assert product_one.pk in price_infos
    assert product_two.pk in price_infos

    first_price_info = price_infos[product_one.pk]
    second_price_info = price_infos[product_two.pk]

    assert first_price_info.price == price(100)
    assert first_price_info.base_price == price(150)
    assert first_price_info.is_discounted

    assert second_price_info.price == price(200)
    assert second_price_info.base_price == price(250)
    assert second_price_info.is_discounted