Commit 4f56b762 authored by Rafael Monnerat's avatar Rafael Monnerat

Redirect url and tests

See merge request nexedi/slapos.core!277
parents cd6c250c 4962d490
......@@ -38,7 +38,8 @@ class TestSlapOSXHTML(SlapOSTestCaseMixin, testXHTML.TestXHTML):
'erp5_run_my_doc', 'erp5_web_renderjs',
'erp5_corporate_identity',
'erp5_corporate_identity_web',
'erp5_notebook', 'erp5_officejs_notebook')
'erp5_notebook', 'erp5_officejs_notebook',
'erp5_web_js_style_ui')
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
# Live tests all uses the same request. For now we remove cell from
......
......@@ -17,7 +17,7 @@ if token:
if error:
base_url = web_site.absolute_url()
redirect_url = "%s/#order?name=%s&email=%s&amount=%s&subscription_reference=%s&token=%s&error=%s" % (
redirect_url = "%s/order?field_your_reservation_name=%s&field_your_reservation_email=%s&field_your_reservation_number_of_machines=%s&field_your_reservation_network=%s&field_your_reservation_invitation_token=%s&portal_status_message=%s" % (
base_url,
user_input_dict['name'],
email,
......@@ -34,14 +34,14 @@ person, person_is_new = context.SubscriptionRequest_createUser(email, user_input
# Check if user is already exist, otherwise redirect to ask confirmation
if confirmation_required and not person_is_new:
base_url = web_site.absolute_url()
redirect_url = "%s/#order_confirmation?name=%s&email=%s&amount=%s&subscription_reference=%s" % (
redirect_url = "%s/order_confirmation?field_your_reservation_name=%s&field_your_reservation_email=%s&field_your_reservation_number_of_machines=%s&field_your_reservation_network=%s" % (
base_url,
person.getTitle(),
person.getDefaultEmailText(),
user_input_dict["amount"],
subscription_reference)
if token:
redirect_url += "&token=%s" % token
redirect_url += "&field_your_reservation_invitation_token=%s" % token
return context.REQUEST.RESPONSE.redirect(redirect_url)
if target_language is None:
......
......@@ -353,8 +353,9 @@ class Test0SubscriptionRequestModule_requestSubscriptionProxy(TestSubscriptionSk
email=email, subscription_reference=subscription_reference,
confirmation_required=True, user_input_dict=user_input_dict)
self.assertTrue(response.endswith("#order_confirmation?name=Member Template&email=%s&amount=1&subscription_reference=test_subscription_reference" % email), response)
self.assertTrue(
response.endswith(
"order_confirmation?field_your_reservation_name=Member Template&field_your_reservation_email=%s&field_your_reservation_number_of_machines=1&field_your_reservation_network=test_subscription_reference" % email), response)
# Missing tests XXXX
class TestSubscriptionRequest_applyCondition(TestSubscriptionSkinsMixin):
......
......@@ -18,7 +18,8 @@ def wrapWithShadow(payment_transaction, web_site, person_relative_url):
title='User navigation script for %s' % payment_transaction.getTitle(),
destination_section=person_relative_url,
)
if web_site:
context.REQUEST.set('base_url', '%s/wechat_payment' % web_site.absolute_url())
system_event.generateManualPaymentPage()
return system_event.contentValues(
......
......@@ -691,6 +691,37 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
"%s do not start with %s" % (redirected_url, expected))
transaction.abort()
def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self):
person = self.makePerson()
invoice = self.createWechatSaleInvoiceTransaction(
destination_section=person.getRelativeUrl())
self.tic()
payment = invoice.SaleInvoiceTransaction_getWechatPaymentRelatedValue()
payment.setResourceValue(self.portal.currency_module.EUR)
payment_transaction_id = payment.getId()
web_site = self.portal.web_site_module.newContent(portal_type='Web Site')
self.tic()
self.login(person.getUserId())
self._simulatePaymentTransaction_getVADSUrlDict()
try:
def callFakeWechatApi(self, URL, wechat_dict):
return {"result_code": 'SUCCESS', "code_url": 'weixin://wxpay/bizpayurl?pr=AAAAA' }
original_callWechatApi = WechatService.callWechatApi
WechatService.callWechatApi = callFakeWechatApi
try:
redirected_url = payment.PaymentTransaction_redirectToManualWechatPayment(web_site)
finally:
WechatService.callWechatApi = original_callWechatApi
finally:
self._dropPaymentTransaction_getVADSUrlDict()
self.assertEqual(payment.PaymentTransaction_getTotalPayablePrice(), 0)
expected = "%s/wechat_payment?trade_no=%s&price=0&payment_url=weixin://wxpay/bizpayurl?pr=" % (web_site.absolute_url(), payment_transaction_id)
self.assertTrue(redirected_url.startswith(expected),
"%s do not start with %s" % (redirected_url, expected))
transaction.abort()
def test_PaymentTransaction_redirectToManualWechatPayment_already_registered(self):
person = self.makePerson()
......
......@@ -16,6 +16,11 @@ wechat_dict = {
'body': "Rapid Space Virtual Machine".encode('utf-8')
}
base_url = context.REQUEST.get('base_url', '')
if base_url:
wechat_dict['base_url'] = base_url
html_document = context.WechatEvent_callWechatServiceNavigation(state_change, wechat_dict)
wechat_event.newContent(
title='Shown Page',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment