예제 #1
0
def test_set_taxful_price_works_with_product_id(rf):
    request, shop, group = initialize_test(rf, True)

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

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

    spm = SimplePricingModule()
    pricing_context = spm.get_context_from_request(request)
    price_info = spm.get_price_info(pricing_context,
                                    product=product.pk,
                                    quantity=1)

    assert price_info.price == TaxfulPrice(250)
    assert price_info.includes_tax

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

    assert pp.includes_tax
    assert pp == TaxfulPrice("250")
예제 #2
0
def test_zero_default_price(rf):
    request, shop, group = initialize_test(rf, True)

    # create a product with zero price
    product = create_product("random-1", shop=shop, default_price=0)

    SimpleProductPrice.objects.create(product=product, group=group, shop=shop, price=50)

    spm = SimplePricingModule()
    pricing_context = spm.get_context_from_request(request)
    price_info = spm.get_price_info(pricing_context, product)

    assert price_info.price == TaxfulPrice(50)
예제 #3
0
def test_zero_default_price(rf):
    request, shop, group = initialize_test(rf, True)
    price = shop.create_price

    # create a product with zero price
    product = create_product("random-1", shop=shop, default_price=0)

    SimpleProductPrice.objects.create(product=product, group=group, shop=shop, price_value=50)

    spm = SimplePricingModule()
    pricing_context = spm.get_context_from_request(request)
    price_info = spm.get_price_info(pricing_context, product)

    assert price_info.price == price(50)
예제 #4
0
def test_no_customer(rf):
    shop = get_default_shop()
    group = get_default_customer_group()

    product = create_product("random-1", shop=shop, default_price=100)

    SimpleProductPrice.objects.create(product=product, group=group, shop=shop, price=50)

    request = rf.get("/")
    request.shop = shop

    spm = SimplePricingModule()
    pricing_context = spm.get_context_from_request(request)

    price_info = spm.get_price_info(pricing_context, product)

    assert price_info.price == TaxfulPrice(100)
예제 #5
0
def test_set_taxful_price_works_with_product_id(rf):
    request, shop, group = initialize_test(rf, True)
    price = shop.create_price

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

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

    spm = SimplePricingModule()
    pricing_context = spm.get_context_from_request(request)
    price_info = spm.get_price_info(pricing_context, product=product.pk, quantity=1)

    assert price_info.price == price(250)

    assert product.get_price(pricing_context, quantity=1) == price(250)
예제 #6
0
def test_no_customer(rf):
    shop = get_default_shop()
    group = get_default_customer_group()
    price = shop.create_price

    product = create_product("random-1", shop=shop, default_price=100)

    SimpleProductPrice.objects.create(product=product, group=group, shop=shop, price_value=50)

    request = rf.get("/")
    request.shop = shop

    spm = SimplePricingModule()
    pricing_context = spm.get_context_from_request(request)

    price_info = spm.get_price_info(pricing_context, product)

    assert price_info.price == price(100)