def test_checkout_shipping_method_setter(): shipping_method = Mock(id=1) checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code') assert checkout.modified is False checkout.shipping_method = shipping_method assert checkout.modified is True assert checkout.storage['shipping_method_country_id'] == 1
def test_view_get_taxed_total_with_shipping( tax_rates_countries, product_in_stock, checkout: Checkout, tax_price_factory, multiple_shipping_methods, request_checkout): variant = product_in_stock.variants.get() checkout.cart.add(variant, 1) with request_checkout: for shipping_method in multiple_shipping_methods: for country, tax_rate in tax_rates_countries.items(): checkout.shipping_method = shipping_method cart_total = float(checkout.get_total().net) expected_total = cart_total * (1 + tax_rate) resp = tax_price_factory(country) assert resp['rate'] == tax_rate assert resp['gross'] == expected_total