def test_payload_add_customer_no_application(payment_provider,
                                             berth_order: Order):
    berth_order.customer_email = "*****@*****.**"
    berth_order.customer_first_name = "Matti"
    berth_order.customer_last_name = "Virtanen"
    berth_order.customer_address = "Street 1"
    berth_order.customer_zip_code = "33100"
    berth_order.customer_city = "Tampere"
    berth_order.lease.application = None

    payload = {}
    payment_provider.payload_add_customer(payload, berth_order)

    assert payload.get("email") == berth_order.customer_email

    customer = payload.get("customer")

    assert customer.get(
        "firstname") == berth_order.customer_first_name.capitalize()
    assert customer.get(
        "lastname") == berth_order.customer_last_name.capitalize()
    assert customer.get("email") == berth_order.customer_email
    assert customer.get("address_street") == berth_order.customer_address
    assert customer.get("address_zip") == berth_order.customer_zip_code
    assert customer.get(
        "address_city") == berth_order.customer_city.capitalize()
def test_payload_add_customer_success(payment_provider,
                                      order_with_products: Order):
    """Test the customer data from order is added correctly into payload"""

    # it should not use this value if application is present
    order_with_products.customer_first_name = "first_name"

    payload = {}
    payment_provider.payload_add_customer(payload, order_with_products)

    assert "email" in payload
    assert payload.get("email") == order_with_products.lease.application.email

    assert "customer" in payload
    customer = payload.get("customer")
    assert (customer.get("firstname") ==
            order_with_products.lease.application.first_name.capitalize())
    assert (customer.get("lastname") ==
            order_with_products.lease.application.last_name.capitalize())
    assert customer.get("email") == order_with_products.lease.application.email
    assert (customer.get("address_street") ==
            order_with_products.lease.application.address)
    assert customer.get(
        "address_zip") == order_with_products.lease.application.zip_code
    assert (customer.get("address_city") ==
            order_with_products.lease.application.municipality.capitalize())