def test_get_checkout_context_no_shipping(request_checkout_with_item, vatlayer): checkout = request_checkout_with_item shipment_option = get_shipping_price_estimate( checkout.get_subtotal().gross, checkout.get_total_weight(), "PL", vatlayer ) checkout_data = utils.get_checkout_context( checkout, None, vatlayer, currency="USD", shipping_range=shipment_option ) checkout_total = checkout_data["checkout_total"] assert checkout_total == TaxedMoney( net=Money("8.13", "USD"), gross=Money(10, "USD") ) assert checkout_data["total_with_shipping"].start == checkout_total
def test_get_checkout_context(request_checkout_with_item, shipping_zone, vatlayer): checkout = request_checkout_with_item shipment_option = get_shipping_price_estimate( checkout.get_subtotal().gross, checkout.get_total_weight(), "PL", vatlayer ) checkout_data = utils.get_checkout_context( checkout, None, vatlayer, currency="USD", shipping_range=shipment_option ) assert checkout_data["checkout_total"] == TaxedMoney( net=Money("8.13", "USD"), gross=Money(10, "USD") ) assert checkout_data["total_with_shipping"].start == TaxedMoney( net=Money("16.26", "USD"), gross=Money(20, "USD") )
def test_get_checkout_context_no_shipping(checkout_with_single_item): shipment_option = get_shipping_price_estimate( checkout_with_single_item.get_subtotal(), checkout_with_single_item.get_total_weight(), "PL", ) checkout_data = utils.get_checkout_context(checkout_with_single_item, None, currency="USD", shipping_range=shipment_option) checkout_total = checkout_data["checkout_total"] assert checkout_total == TaxedMoney(net=Money("10.00", "USD"), gross=Money("10.00", "USD")) assert checkout_data["total_with_shipping"].start == checkout_total
def test_get_checkout_data_no_shipping(request_checkout_with_item, vatlayer): checkout = request_checkout_with_item shipment_option = get_shipping_price_estimate( checkout.get_subtotal().gross, checkout.get_total_weight(), 'PL', vatlayer) checkout_data = utils.get_checkout_context(checkout, None, vatlayer, currency='USD', shipping_range=shipment_option) checkout_total = checkout_data['checkout_total'] assert checkout_total == TaxedMoney(net=Money('8.13', 'USD'), gross=Money(10, 'USD')) assert checkout_data['total_with_shipping'].start == checkout_total
def test_get_checkout_context(checkout_with_voucher, vatlayer): line_price = TaxedMoney(net=Money("24.39", "USD"), gross=Money("30.00", "USD")) expected_data = { "checkout": checkout_with_voucher, "checkout_are_taxes_handled": True, "checkout_lines": [(checkout_with_voucher.lines.first(), line_price)], "checkout_shipping_price": ZERO_TAXED_MONEY, "checkout_subtotal": line_price, "checkout_total": line_price - checkout_with_voucher.discount_amount, "shipping_required": checkout_with_voucher.is_shipping_required(), "total_with_shipping": TaxedMoneyRange(start=line_price, stop=line_price), } data = get_checkout_context(checkout_with_voucher, discounts=None, taxes=vatlayer) assert data == expected_data
def test_get_checkout_context_no_shipping(checkout_with_single_item, address): checkout = checkout_with_single_item checkout.shipping_address = address checkout.save(update_fields=["shipping_address"]) shipment_option = get_shipping_price_estimate( checkout, discounts=None, country_code="PL" ) checkout_data = utils.get_checkout_context( checkout, None, currency="USD", shipping_range=shipment_option ) checkout_total = checkout_data["checkout_total"] assert checkout_total == TaxedMoney( net=Money("10.00", "USD"), gross=Money("10.00", "USD") ) assert checkout_data["total_with_shipping"].start == checkout_total
def test_get_checkout_context(checkout_with_voucher): line_price = TaxedMoney(net=Money("30.00", "USD"), gross=Money("30.00", "USD")) expected_data = { "checkout": checkout_with_voucher, "checkout_are_taxes_handled": taxes_are_enabled(), "checkout_lines": [(checkout_with_voucher.lines.first(), line_price)], "checkout_shipping_price": zero_taxed_money(), "checkout_subtotal": line_price, "checkout_total": line_price - checkout_with_voucher.discount_amount, "shipping_required": checkout_with_voucher.is_shipping_required(), "total_with_shipping": TaxedMoneyRange(start=line_price, stop=line_price), } data = get_checkout_context(checkout_with_voucher, discounts=None) assert data == expected_data
def test_get_checkout_context(checkout_with_voucher, vatlayer): line_price = TaxedMoney(net=Money('24.39', 'USD'), gross=Money('30.00', 'USD')) expected_data = { 'checkout': checkout_with_voucher, 'checkout_are_taxes_handled': True, 'checkout_lines': [(checkout_with_voucher.lines.first(), line_price)], 'checkout_shipping_price': ZERO_TAXED_MONEY, 'checkout_subtotal': line_price, 'checkout_total': line_price - checkout_with_voucher.discount_amount, 'shipping_required': checkout_with_voucher.is_shipping_required(), 'total_with_shipping': TaxedMoneyRange(start=line_price, stop=line_price) } data = get_checkout_context(checkout_with_voucher, discounts=None, taxes=vatlayer) assert data == expected_data