Commit 6cca1c8d authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_payzen: (Test) always create Integrator Site and setup preferences

  whenever the tests need it.
parent ca088953
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
# #
############################################################################## ##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort from erp5.component.test.testSlapOSPayzenSkins import TestSlapOSPayzenMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime from DateTime import DateTime
class TestSlapOSPayzenUpdateStartedPayment(SlapOSTestCaseMixinWithAbort): class TestSlapOSPayzenUpdateStartedPayment(TestSlapOSPayzenMixin):
def test_not_started_payment(self): def test_not_started_payment(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -81,7 +81,7 @@ class Foo: ...@@ -81,7 +81,7 @@ class Foo:
def updateStatus(self): def updateStatus(self):
context.stop() context.stop()
return Foo() return Foo()
""" ) """)
self.commit() self.commit()
def _simulatePaymentTransaction_createNotPaidPayzenEvent(self): def _simulatePaymentTransaction_createNotPaidPayzenEvent(self):
...@@ -168,7 +168,7 @@ return Foo() ...@@ -168,7 +168,7 @@ return Foo()
'*args, **kwargs', '*args, **kwargs',
'# Script body\n' '# Script body\n'
"""portal_workflow = context.portal_workflow """portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by PaymentTransaction_updateStatus') """ ) portal_workflow.doActionFor(context, action='edit_action', comment='Visited by PaymentTransaction_updateStatus') """)
self.commit() self.commit()
def _dropPaymentTransaction_updateStatus(self): def _dropPaymentTransaction_updateStatus(self):
......
...@@ -25,23 +25,71 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort ...@@ -25,23 +25,71 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from DateTime import DateTime from DateTime import DateTime
from zExceptions import Unauthorized from zExceptions import Unauthorized
class PayzenServiceTestCase(SlapOSTestCaseMixin): class TestSlapOSPayzenMixin(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self.payzen_secure_payment = self.portal.portal_secure_payments.newContent( self.payzen_secure_payment = self.portal.portal_secure_payments.newContent(
portal_type="Payzen Service", portal_type="Payzen Service",
reference="PSERV-Payzen-Test" reference="PSERV-Payzen-Test-%s" % self.generateNewId()
) )
# Include a simple Integration site
self.integration_site = self.portal.portal_integrations.newContent(
title="Integration site for: %s" % (self.payzen_secure_payment),
reference="payzen",
portal_type="Integration Site"
)
self.integration_site.newContent(
id="Causality",
portal_type="Integration Base Category Mapping",
default_source_reference="Causality",
default_destination_reference="causality"
)
resource_map = self.integration_site.newContent(
id="Resource",
portal_type="Integration Base Category Mapping",
default_source_reference="Resource",
default_destination_reference="resource"
)
resource_map.newContent(
# This is required for integration
id='978',
portal_type="Integration Category Mapping",
default_destination_reference='resource/currency_module/EUR',
default_source_reference='978'
)
system_preference = self.portal.portal_preferences.slapos_default_system_preference
self.older_service_reference = system_preference.getPreferredPayzenPaymentServiceReference()
system_preference.setPreferredPayzenPaymentServiceReference(
self.payzen_secure_payment.getReference())
self.older_integration_site = system_preference.getPreferredPayzenIntegrationSite()
system_preference.setPreferredPayzenIntegrationSite(
self.integration_site.getRelativeUrl()
)
self.tic() self.tic()
def beforeTearDown(self): def beforeTearDown(self):
SlapOSTestCaseMixin.beforeTearDown(self) SlapOSTestCaseMixin.beforeTearDown(self)
self.portal.portal_secure_payments.manage_delObjects( self.portal.portal_secure_payments.manage_delObjects(
ids=[self.payzen_secure_payment.getId()]) ids=[self.payzen_secure_payment.getId()])
self.portal.portal_integrations.manage_delObjects(
ids=[self.integration_site.getId()])
system_preference = self.portal.portal_preferences.slapos_default_system_preference
system_preference.setPreferredPayzenPaymentServiceReference(
self.older_service_reference)
system_preference.setPreferredPayzenIntegrationSite(
self.older_integration_site
)
self.tic() self.tic()
class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort): class TestSlapOSCurrency_getIntegrationMapping(TestSlapOSPayzenMixin):
def test_integratedCurrency(self): def test_integratedCurrency(self):
currency = self.portal.currency_module.EUR currency = self.portal.currency_module.EUR
...@@ -76,7 +124,7 @@ class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbo ...@@ -76,7 +124,7 @@ class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbo
date, REQUEST={}) date, REQUEST={})
class TestSlapOSPaymentTransaction_getPayzenId(SlapOSTestCaseMixinWithAbort): class TestSlapOSPaymentTransaction_getPayzenId(TestSlapOSPayzenMixin):
def test_getPayzenId_newPaymentTransaction(self): def test_getPayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction() payment_transaction = self.createPaymentTransaction()
...@@ -116,7 +164,7 @@ class TestSlapOSPaymentTransaction_getPayzenId(SlapOSTestCaseMixinWithAbort): ...@@ -116,7 +164,7 @@ class TestSlapOSPaymentTransaction_getPayzenId(SlapOSTestCaseMixinWithAbort):
REQUEST={}) REQUEST={})
class TestSlapOSPaymentTransaction_generatePayzenId(SlapOSTestCaseMixinWithAbort): class TestSlapOSPaymentTransaction_generatePayzenId(TestSlapOSPayzenMixin):
def test_generatePayzenId_newPaymentTransaction(self): def test_generatePayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction() payment_transaction = self.createPaymentTransaction()
...@@ -176,7 +224,7 @@ class TestSlapOSPaymentTransaction_generatePayzenId(SlapOSTestCaseMixinWithAbort ...@@ -176,7 +224,7 @@ class TestSlapOSPaymentTransaction_generatePayzenId(SlapOSTestCaseMixinWithAbort
REQUEST={}) REQUEST={})
class TestSlapOSPaymentTransaction_createPayzenEvent(PayzenServiceTestCase): class TestSlapOSPaymentTransaction_createPayzenEvent(TestSlapOSPayzenMixin):
def test_createPayzenEvent_REQUEST_disallowed(self): def test_createPayzenEvent_REQUEST_disallowed(self):
payment_transaction = self.createPaymentTransaction() payment_transaction = self.createPaymentTransaction()
...@@ -643,7 +691,7 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f ...@@ -643,7 +691,7 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f
'Aborting refused payzen payment.', 'Aborting refused payzen payment.',
payment.workflow_history['accounting_workflow'][-1]['comment']) payment.workflow_history['accounting_workflow'][-1]['comment'])
class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(PayzenServiceTestCase): class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(TestSlapOSPayzenMixin):
def test_getPayzenServiceRelativeUrl_REQUEST_disallowed(self): def test_getPayzenServiceRelativeUrl_REQUEST_disallowed(self):
self.assertRaises( self.assertRaises(
...@@ -663,7 +711,7 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(PayzenServiceTestCase): ...@@ -663,7 +711,7 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(PayzenServiceTestCase):
class TestSlapOSPayzenPaymentTransaction_redirectToManualPayzenPayment( class TestSlapOSPayzenPaymentTransaction_redirectToManualPayzenPayment(
PayzenServiceTestCase): TestSlapOSPayzenMixin):
@simulate("PaymentTransaction_getVADSUrlDict", '*args, **kwargs', @simulate("PaymentTransaction_getVADSUrlDict", '*args, **kwargs',
"""payment_transaction_url = context.getRelativeUrl() """payment_transaction_url = context.getRelativeUrl()
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
############################################################################## ##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort, \ from erp5.component.test.SlapOSTestCaseMixin import simulate
simulate from erp5.component.test.testSlapOSPayzenSkins import TestSlapOSPayzenMixin
import lxml.html import lxml.html
from DateTime import DateTime from DateTime import DateTime
...@@ -34,7 +34,7 @@ vads_url_refused = 'http://example.org/refused' ...@@ -34,7 +34,7 @@ vads_url_refused = 'http://example.org/refused'
vads_url_success = 'http://example.org/success' vads_url_success = 'http://example.org/success'
vads_url_return = 'http://example.org/return' vads_url_return = 'http://example.org/return'
class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort): class TestSlapOSPayzenInterfaceWorkflow(TestSlapOSPayzenMixin):
def createPayzenService(self): def createPayzenService(self):
self.payzen_secure_payment = self.portal.portal_secure_payments.newContent( self.payzen_secure_payment = self.portal.portal_secure_payments.newContent(
...@@ -43,14 +43,6 @@ class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort): ...@@ -43,14 +43,6 @@ class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
) )
self.tic() self.tic()
def beforeTearDown(self):
SlapOSTestCaseMixinWithAbort.beforeTearDown(self)
if getattr(self, "payzen_secure_payment", None):
self.portal.portal_secure_payments.manage_delObjects(
ids=[self.payzen_secure_payment.getId()])
self.tic()
slapos_payzen_html = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> slapos_payzen_html = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
......
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