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 @@
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from erp5.component.test.testSlapOSPayzenSkins import TestSlapOSPayzenMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime
class TestSlapOSPayzenUpdateStartedPayment(SlapOSTestCaseMixinWithAbort):
class TestSlapOSPayzenUpdateStartedPayment(TestSlapOSPayzenMixin):
def test_not_started_payment(self):
new_id = self.generateNewId()
......@@ -81,7 +81,7 @@ class Foo:
def updateStatus(self):
context.stop()
return Foo()
""" )
""")
self.commit()
def _simulatePaymentTransaction_createNotPaidPayzenEvent(self):
......@@ -168,7 +168,7 @@ return Foo()
'*args, **kwargs',
'# Script body\n'
"""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()
def _dropPaymentTransaction_updateStatus(self):
......
......@@ -25,23 +25,71 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from DateTime import DateTime
from zExceptions import Unauthorized
class PayzenServiceTestCase(SlapOSTestCaseMixin):
class TestSlapOSPayzenMixin(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.payzen_secure_payment = self.portal.portal_secure_payments.newContent(
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()
def beforeTearDown(self):
SlapOSTestCaseMixin.beforeTearDown(self)
self.portal.portal_secure_payments.manage_delObjects(
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()
class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort):
class TestSlapOSCurrency_getIntegrationMapping(TestSlapOSPayzenMixin):
def test_integratedCurrency(self):
currency = self.portal.currency_module.EUR
......@@ -76,7 +124,7 @@ class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbo
date, REQUEST={})
class TestSlapOSPaymentTransaction_getPayzenId(SlapOSTestCaseMixinWithAbort):
class TestSlapOSPaymentTransaction_getPayzenId(TestSlapOSPayzenMixin):
def test_getPayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction()
......@@ -116,7 +164,7 @@ class TestSlapOSPaymentTransaction_getPayzenId(SlapOSTestCaseMixinWithAbort):
REQUEST={})
class TestSlapOSPaymentTransaction_generatePayzenId(SlapOSTestCaseMixinWithAbort):
class TestSlapOSPaymentTransaction_generatePayzenId(TestSlapOSPayzenMixin):
def test_generatePayzenId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction()
......@@ -176,7 +224,7 @@ class TestSlapOSPaymentTransaction_generatePayzenId(SlapOSTestCaseMixinWithAbort
REQUEST={})
class TestSlapOSPaymentTransaction_createPayzenEvent(PayzenServiceTestCase):
class TestSlapOSPaymentTransaction_createPayzenEvent(TestSlapOSPayzenMixin):
def test_createPayzenEvent_REQUEST_disallowed(self):
payment_transaction = self.createPaymentTransaction()
......@@ -643,7 +691,7 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f
'Aborting refused payzen payment.',
payment.workflow_history['accounting_workflow'][-1]['comment'])
class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(PayzenServiceTestCase):
class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(TestSlapOSPayzenMixin):
def test_getPayzenServiceRelativeUrl_REQUEST_disallowed(self):
self.assertRaises(
......@@ -663,7 +711,7 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(PayzenServiceTestCase):
class TestSlapOSPayzenPaymentTransaction_redirectToManualPayzenPayment(
PayzenServiceTestCase):
TestSlapOSPayzenMixin):
@simulate("PaymentTransaction_getVADSUrlDict", '*args, **kwargs',
"""payment_transaction_url = context.getRelativeUrl()
......
......@@ -18,8 +18,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort, \
simulate
from erp5.component.test.SlapOSTestCaseMixin import simulate
from erp5.component.test.testSlapOSPayzenSkins import TestSlapOSPayzenMixin
import lxml.html
from DateTime import DateTime
......@@ -34,7 +34,7 @@ vads_url_refused = 'http://example.org/refused'
vads_url_success = 'http://example.org/success'
vads_url_return = 'http://example.org/return'
class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
class TestSlapOSPayzenInterfaceWorkflow(TestSlapOSPayzenMixin):
def createPayzenService(self):
self.payzen_secure_payment = self.portal.portal_secure_payments.newContent(
......@@ -43,14 +43,6 @@ class TestSlapOSPayzenInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
)
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">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<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