def test_clean_checkout_no_shipping_address(checkout_with_item, shipping_method): checkout = checkout_with_item checkout.shipping_method = shipping_method checkout.save() with pytest.raises(ValidationError) as e: clean_checkout(checkout, None, None) msg = "Shipping address is not set" assert e.value.error_list[0].message == msg
def test_ready_to_place_order_no_shipping_method(checkout_with_item, address): checkout = checkout_with_item checkout.shipping_address = address checkout.save() with pytest.raises(ValidationError) as e: clean_checkout(checkout, None, None) msg = 'Shipping method is not set' assert e.value.error_list[0].message == msg
def test_clean_checkout_no_payment(checkout_with_item, shipping_method, address): checkout = checkout_with_item checkout.shipping_method = shipping_method checkout.address = address checkout.save() with pytest.raises(ValidationError) as e: clean_checkout(checkout, None) msg = "Provided payment methods can not cover the checkout's total amount" assert e.value.error_list[0].message == msg
def test_clean_checkout_no_payment(checkout_with_item, shipping_method, address): checkout = checkout_with_item checkout.shipping_address = address checkout.shipping_method = shipping_method checkout.billing_address = address checkout.save() with pytest.raises(ValidationError) as e: clean_checkout(checkout, None, None) msg = "Provided payment methods can not cover the checkout's total amount" assert e.value.error_list[0].message == msg
def test_clean_checkout_invalid_shipping_method( checkout_with_item, address, shipping_zone_without_countries): checkout = checkout_with_item checkout.shipping_address = address shipping_method = shipping_zone_without_countries.shipping_methods.first() checkout.shipping_method = shipping_method checkout.save() with pytest.raises(ValidationError) as e: clean_checkout(checkout, None, None) msg = "Shipping method is not valid for your shipping address" assert e.value.error_list[0].message == msg
def test_ready_to_place_order_no_payment( checkout_with_item, shipping_method, address): checkout = checkout_with_item checkout.shipping_address = address checkout.shipping_method = shipping_method checkout.billing_address = address checkout.save() with pytest.raises(ValidationError) as e: clean_checkout(checkout, None, None) msg = 'Provided payment methods can not cover the checkout\'s total amount' assert e.value.error_list[0].message == msg
def test_clean_checkout_invalid_shipping_method( checkout_with_item, address, shipping_zone_without_countries ): checkout = checkout_with_item checkout.shipping_address = address shipping_method = shipping_zone_without_countries.shipping_methods.first() checkout.shipping_method = shipping_method checkout.save() with pytest.raises(ValidationError) as e: clean_checkout(checkout, None, None) msg = "Shipping method is not valid for your shipping address" assert e.value.error_list[0].message == msg
def test_clean_checkout(checkout_with_item, payment_dummy, address, shipping_method): checkout = checkout_with_item checkout.shipping_address = address checkout.shipping_method = shipping_method checkout.billing_address = address checkout.save() total = checkout.get_total() payment = payment_dummy payment.is_active = True payment.order = None payment.total = total.gross.amount payment.currency = total.gross.currency payment.checkout = checkout payment.save() # Shouldn't raise any errors clean_checkout(checkout, None, None)