From 03e358bcd760476e1fb5765c1904fb168f0e66b3 Mon Sep 17 00:00:00 2001 From: Gabriel Monnerat <gabriel@tiolive.com> Date: Tue, 10 Jul 2012 15:59:50 -0300 Subject: [PATCH] clean up reportPaymentStatus function on PaypalService to call PaypalService_reportPaymentStatus script regardless of the outcome of the status and added one test to cover this method --- .../DocumentTemplateItem/PaypalService.py | 6 ++---- .../testERP5PaypalSecurePayment.py | 17 +++++++++++++++-- bt5/erp5_paypal_secure_payment/bt/revision | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/bt5/erp5_paypal_secure_payment/DocumentTemplateItem/PaypalService.py b/bt5/erp5_paypal_secure_payment/DocumentTemplateItem/PaypalService.py index 0069533bbf..a572bc5340 100644 --- a/bt5/erp5_paypal_secure_payment/DocumentTemplateItem/PaypalService.py +++ b/bt5/erp5_paypal_secure_payment/DocumentTemplateItem/PaypalService.py @@ -103,8 +103,6 @@ class PaypalService(XMLObject): request.add_header("Content-type", "application/x-www-form-urlencoded") response = urlopen(request) status = response.read() - method = self._getTypeBasedMethod("reportPaymentStatus") LOG("PaypalService status", DEBUG, status) - if method and status == "VERIFIED": - method(REQUEST=REQUEST) - return True \ No newline at end of file + self._getTypeBasedMethod("reportPaymentStatus")(REQUEST=REQUEST) + return status == "VERIFIED" \ No newline at end of file diff --git a/bt5/erp5_paypal_secure_payment/TestTemplateItem/testERP5PaypalSecurePayment.py b/bt5/erp5_paypal_secure_payment/TestTemplateItem/testERP5PaypalSecurePayment.py index 710d1da888..695cbfeb73 100644 --- a/bt5/erp5_paypal_secure_payment/TestTemplateItem/testERP5PaypalSecurePayment.py +++ b/bt5/erp5_paypal_secure_payment/TestTemplateItem/testERP5PaypalSecurePayment.py @@ -26,7 +26,7 @@ ############################################################################## import random -from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase +from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, get_request def getMessageList(o): @@ -98,4 +98,17 @@ business=business@sample.com""") finally: self.portal.portal_skins.custom.manage_delObjects([pt_id]) # flush skin cache - self.portal.changeSkin(None) \ No newline at end of file + self.portal.changeSkin(None) + + def test_reportPaymentStatus(self): + script_id = "Base_paymentResponse" + custom_skin = self.portal.portal_skins.custom + custom_skin.manage_addProduct['PythonScripts']\ + .manage_addPythonScript(id=script_id) + script = custom_skin[script_id] + script.ZPythonScript_edit('**kw', "if kw.has_key('cmd'):\n return 'VERIFIED'") + self.tic() + script_absolute_url = script.absolute_url() + self.service.edit(link_url_string=script_absolute_url) + response = self.service.reportPaymentStatus(get_request()) + self.assertTrue(response) \ No newline at end of file diff --git a/bt5/erp5_paypal_secure_payment/bt/revision b/bt5/erp5_paypal_secure_payment/bt/revision index d8263ee986..e440e5c842 100644 --- a/bt5/erp5_paypal_secure_payment/bt/revision +++ b/bt5/erp5_paypal_secure_payment/bt/revision @@ -1 +1 @@ -2 \ No newline at end of file +3 \ No newline at end of file -- 2.30.9