예제 #1
0
def test_check_for_draft_order_errors(order_with_lines):
    errors = check_for_draft_order_errors(order_with_lines, [])
    assert not errors

    order_with_no_lines = Mock(spec=Order)
    order_with_no_lines.get_total_quantity = MagicMock(return_value=0)
    errors = check_for_draft_order_errors(order_with_no_lines, [])
    assert errors[0].message == 'Could not create order without any products.'

    order_with_wrong_shipping = Mock(spec=Order)
    order_with_wrong_shipping.shipping_method = False
    errors = check_for_draft_order_errors(order_with_wrong_shipping, [])
    msg = 'Shipping method is not valid for chosen shipping address'
    assert errors[0].message == msg
예제 #2
0
def test_check_for_draft_order_errors_wrong_shipping(order_with_lines):
    order = order_with_lines
    shipping_zone = order.shipping_method.shipping_zone
    shipping_zone.countries = ['DE']
    shipping_zone.save()
    assert order.shipping_address.country.code not in shipping_zone.countries
    errors = check_for_draft_order_errors(order, [])
    msg = 'Shipping method is not valid for chosen shipping address'
    assert errors[0].message == msg
예제 #3
0
def test_check_for_draft_order_errors_no_order_lines(order):
    errors = check_for_draft_order_errors(order, [])
    assert errors[0].message == 'Could not create order without any products.'
예제 #4
0
def test_check_for_draft_order_errors(order_with_lines):
    errors = check_for_draft_order_errors(order_with_lines, [])
    assert not errors