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_send_payment_notification_example_email(order: Order): order.customer_email = "*****@*****.**" with pytest.raises(ValidationError) as exception: send_payment_notification(order, RequestFactory().request()) assert "Missing customer email" in str(exception)
def test_initiate_refund_no_order_email_or_application( provider_base_config: dict, order: Order ): """Test the request creator constructs the payload base and returns a url that contains a token""" request = RequestFactory().request() order.status = OrderStatus.PAID order.customer_email = None order.lease.status = LeaseStatus.PAID order.lease.application = None order.lease.save() order.save() OrderToken.objects.create( order=order, token="12345", valid_until=now() - relativedelta(days=7) ) payment_provider = create_bambora_provider(provider_base_config, request) with pytest.raises(ValidationError) as exception: payment_provider.initiate_refund(order) assert "Cannot refund an order that has no email" in str(exception)