Commit 1c60b1d8 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_wechat: Drop hardcoded testing data from the bt5

   Create the documents on the fly on the tests, otherwise it may cause problems on production.
parent dc0f762f
......@@ -34,7 +34,7 @@ from zExceptions import Unauthorized
class TestSlapOSAccounting(SlapOSTestCaseMixin):
def createIntegrationSite(self):
def createIntegrationPayzenSite(self):
# Include a simple Integration site, which is required for
# PaymentTransaction_generatePayzenId
integration_site = self.portal.portal_integrations.newContent(
......@@ -62,6 +62,35 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
)
return integration_site
def createIntegrationWechatSite(self):
# Include a simple Integration site, which is required for
# PaymentTransaction_generateWechatId
integration_site = self.portal.portal_integrations.newContent(
title="Integration site for test_AccountingTransaction_getPaymentState_wechat_waiting_payment",
reference="wechat",
portal_type="Integration Site"
)
integration_site.newContent(
id="Causality",
portal_type="Integration Base Category Mapping",
default_source_reference="Causality",
default_destination_reference="causality"
)
resource_map = integration_site.newContent(
id="Resource",
portal_type="Integration Base Category Mapping",
default_source_reference="Resource",
default_destination_reference="resource"
)
resource_map.newContent(
id='979',
portal_type="Integration Category Mapping",
default_destination_reference='resource/currency_module/CNY',
default_source_reference='979'
)
return integration_site
def createHostingSubscription(self):
new_id = self.generateNewId()
return self.portal.hosting_subscription_module.newContent(
......@@ -188,7 +217,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
system_preference = self.portal.portal_preferences.slapos_default_system_preference
older_integration_site = system_preference.getPreferredPayzenIntegrationSite()
integration_site = self.createIntegrationSite()
integration_site = self.createIntegrationPayzenSite()
system_preference.setPreferredPayzenIntegrationSite(
integration_site.getRelativeUrl()
)
......@@ -302,12 +331,27 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
system_preference = self.portal.portal_preferences.slapos_default_system_preference
older_integration_site = system_preference.getPreferredWechatIntegrationSite()
integration_site = self.createIntegrationWechatSite()
system_preference.setPreferredWechatIntegrationSite(
integration_site.getRelativeUrl()
)
self.tic()
payment.PaymentTransaction_generateWechatId()
self.assertRaises(
ValueError,
invoice.SaleInvoiceTransaction_createReversalSaleInvoiceTransaction,
batch_mode=1)
try:
payment.PaymentTransaction_generateWechatId()
self.assertRaises(
ValueError,
invoice.SaleInvoiceTransaction_createReversalSaleInvoiceTransaction,
batch_mode=1)
finally:
self.portal.portal_integrations.manage_delObjects(
ids=[integration_site.getId()])
system_preference.setPreferredWechatIntegrationSite(
older_integration_site
)
@withAbort
def test_createReversalSaleInvoiceTransaction_wechat_ok(self):
......@@ -439,7 +483,7 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
system_preference = self.portal.portal_preferences.slapos_default_system_preference
older_integration_site = system_preference.getPreferredPayzenIntegrationSite()
integration_site = self.createIntegrationSite()
integration_site = self.createIntegrationPayzenSite()
system_preference.setPreferredPayzenIntegrationSite(
integration_site.getRelativeUrl()
)
......@@ -474,11 +518,27 @@ class TestSlapOSAccounting(SlapOSTestCaseMixin):
created_by_builder=1 # to prevent init script to create lines
)
self.portal.portal_workflow._jumpToStateFor(payment, 'started')
payment.PaymentTransaction_generateWechatId()
self.tic()
self.login(person.getUserId())
self.assertEqual("Waiting for payment confirmation",
system_preference = self.portal.portal_preferences.slapos_default_system_preference
older_integration_site = system_preference.getPreferredWechatIntegrationSite()
integration_site = self.createIntegrationWechatSite()
system_preference.setPreferredWechatIntegrationSite(
integration_site.getRelativeUrl()
)
try:
payment.PaymentTransaction_generateWechatId()
self.tic()
self.login(person.getUserId())
self.assertEqual("Waiting for payment confirmation",
invoice.AccountingTransaction_getPaymentState())
finally:
self.portal.portal_integrations.manage_delObjects(
ids=[integration_site.getId()])
system_preference.setPreferredWechatIntegrationSite(
older_integration_site
)
def test_AccountingTransaction_getPaymentState_payzen_papaid_payment(self):
invoice = self.createStoppedSaleInvoiceTransaction()
......
......@@ -313,10 +313,6 @@
<none/>
</value>
</item>
<item>
<key> <string>preferred_wechat_integration_site</string> </key>
<value> <string>portal_integrations/slapos_wechat_test_integration</string> </value>
</item>
<item>
<key> <string>preffered_force_username_check_in_password</string> </key>
<value> <int>1</int> </value>
......
<local_roles_item>
<local_roles>
<role id='R-SHADOW-PERSON'>
<item>Auditor</item>
<item>Author</item>
</role>
</local_roles>
<local_role_group_ids>
<local_role_group_id id='shadow'>
<principal id='R-SHADOW-PERSON'>Auditor</principal>
<principal id='R-SHADOW-PERSON'>Author</principal>
</local_role_group_id>
</local_role_group_ids>
</local_roles_item>
\ No newline at end of file
<local_roles_item>
<local_roles>
<role id='R-SHADOW-PERSON'>
<item>Auditor</item>
<item>Author</item>
</role>
</local_roles>
<local_role_group_ids>
<local_role_group_id id='shadow'>
<principal id='R-SHADOW-PERSON'>Auditor</principal>
<principal id='R-SHADOW-PERSON'>Author</principal>
</local_role_group_id>
</local_role_group_ids>
</local_roles_item>
\ No newline at end of file
......@@ -37,8 +37,6 @@ open_sale_order_module
organisation_module
person_module
portal_integrations
portal_integrations/slapos_payzen_test_integration
portal_integrations/slapos_wechat_test_integration
project_module
regularisation_request_module
sale_packing_list_module
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Integration Site" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>wechat</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_wechat_test_integration</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Site</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SlapOS Wechat Integration</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Integration Base Category Mapping" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_destination_reference</string> </key>
<value> <string>causality</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Causality</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Causality</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Base Category Mapping</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Integration Base Category Mapping" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_destination_reference</string> </key>
<value> <string>resource</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Resource</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Resource</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Base Category Mapping</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Integration Category Mapping" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_destination_reference</string> </key>
<value> <string>resource/currency_module/CNY</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>CNY</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>979</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Category Mapping</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>979</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Integration Base Category Mapping" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_destination_reference</string> </key>
<value> <string>source_project</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>SourceProject</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SourceProject</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Base Category Mapping</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Wechat Service" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>query_url_string</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>service_mch_id</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>service_api_key</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>service_appid</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>PSERV-Wechat-Test</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_wechat_test</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Wechat Service</string> </value>
</item>
<item>
<key> <string>query_url_string</string> </key>
<value> <string>https://api.mch.weixin.qq.com/pay/orderquery</string> </value>
</item>
<item>
<key> <string>service_api_key</string> </key>
<value> <string>46BBF9D93F1DCFAF38BF48A9FA0218EF</string> </value>
</item>
<item>
<key> <string>service_appid</string> </key>
<value> <string>wx9f5e222240e92043</string> </value>
</item>
<item>
<key> <string>service_mch_id</string> </key>
<value> <string>1555737971</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Wechat</string> </value>
</item>
<item>
<key> <string>wechat_mode</string> </key>
<value> <string>UNITTEST</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Link" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>default_link</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Link</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>url_string</string> </key>
<value> <string>https://apius.mch.weixin.qq.com</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -19,11 +19,11 @@
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from erp5.component.test.testSlapOSWechatSkins import TestSlapOSWechatMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime
class TestSlapOSWechatUpdateStartedPayment(SlapOSTestCaseMixinWithAbort):
class TestSlapOSWechatUpdateStartedPayment(TestSlapOSWechatMixin):
def test_not_started_payment(self):
new_id = self.generateNewId()
......
......@@ -18,7 +18,8 @@
# 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 \
SlapOSTestCaseMixinWithAbort, SlapOSTestCaseMixin
from erp5.component.document.WechatService import WechatService
......@@ -27,7 +28,72 @@ from zExceptions import Unauthorized
import transaction
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSCurrency_getIntegrationMapping(SlapOSTestCaseMixinWithAbort):
class TestSlapOSWechatMixin(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.wechat_secure_payment = self.portal.portal_secure_payments.newContent(
portal_type="Wechat Service",
reference="PSERV-Wechat-Test-%s" % self.generateNewId()
)
# Include a simple Integration site
self.integration_site = self.portal.portal_integrations.newContent(
title="Integration site for: %s" % (self.wechat_secure_payment),
reference="wechat",
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='979',
portal_type="Integration Category Mapping",
default_destination_reference='resource/currency_module/CNY',
default_source_reference='CNY'
)
system_preference = self.portal.portal_preferences.slapos_default_system_preference
self.older_service_reference = system_preference.getPreferredWechatPaymentServiceReference()
system_preference.setPreferredWechatPaymentServiceReference(
self.wechat_secure_payment.getReference())
self.older_integration_site = system_preference.getPreferredWechatIntegrationSite()
system_preference.setPreferredWechatIntegrationSite(
self.integration_site.getRelativeUrl()
)
self.tic()
def beforeTearDown(self):
SlapOSTestCaseMixin.beforeTearDown(self)
self.portal.portal_secure_payments.manage_delObjects(
ids=[self.wechat_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.setPreferredWechatPaymentServiceReference(
self.older_service_reference)
system_preference.setPreferredWechatIntegrationSite(
self.older_integration_site
)
self.tic()
class TestSlapOSCurrency_getIntegrationMapping(TestSlapOSWechatMixin):
def test_integratedCurrency(self):
currency = self.portal.currency_module.CNY
......@@ -62,7 +128,7 @@ class TestSlapOSAccountingTransaction_updateStartDate(SlapOSTestCaseMixinWithAbo
date, REQUEST={})
class TestSlapOSPaymentTransaction_getWechatId(SlapOSTestCaseMixinWithAbort):
class TestSlapOSPaymentTransaction_getWechatId(TestSlapOSWechatMixin):
def test_getWechatId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction()
......@@ -102,7 +168,7 @@ class TestSlapOSPaymentTransaction_getWechatId(SlapOSTestCaseMixinWithAbort):
REQUEST={})
class TestSlapOSPaymentTransaction_generateWechatId(SlapOSTestCaseMixinWithAbort):
class TestSlapOSPaymentTransaction_generateWechatId(TestSlapOSWechatMixin):
def test_generateWechatId_newPaymentTransaction(self):
payment_transaction = self.createPaymentTransaction()
......@@ -164,7 +230,7 @@ class TestSlapOSPaymentTransaction_generateWechatId(SlapOSTestCaseMixinWithAbort
REQUEST={})
class TestSlapOSPaymentTransaction_createWechatEvent(SlapOSTestCaseMixinWithAbort):
class TestSlapOSPaymentTransaction_createWechatEvent(TestSlapOSWechatMixin):
def test_createWechatEvent_REQUEST_disallowed(self):
payment_transaction = self.createPaymentTransaction()
......@@ -174,28 +240,26 @@ class TestSlapOSPaymentTransaction_createWechatEvent(SlapOSTestCaseMixinWithAbor
REQUEST={})
def test_createWechatEvent_newPayment(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
payment_transaction = self.createPaymentTransaction()
wechat_event = payment_transaction.PaymentTransaction_createWechatEvent()
self.assertEqual(wechat_event.getPortalType(), "Wechat Event")
self.assertEqual(wechat_event.getSource(),
"portal_secure_payments/slapos_wechat_test")
self.wechat_secure_payment.getRelativeUrl())
self.assertEqual(wechat_event.getDestination(), payment_transaction.getRelativeUrl())
def test_createWechatEvent_kwParameter(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
self.tic()
payment_transaction = self.createPaymentTransaction()
wechat_event = payment_transaction.PaymentTransaction_createWechatEvent(
title='foo')
self.assertEqual(wechat_event.getPortalType(), "Wechat Event")
self.assertEqual(wechat_event.getSource(),
"portal_secure_payments/slapos_wechat_test")
self.wechat_secure_payment.getRelativeUrl())
self.assertEqual(wechat_event.getDestination(), payment_transaction.getRelativeUrl())
self.assertEqual(wechat_event.getTitle(), "foo")
class TestSlapOSWechatEvent_processUpdate(SlapOSTestCaseMixinWithAbort):
class TestSlapOSWechatEvent_processUpdate(TestSlapOSWechatMixin):
def test_processUpdate_REQUEST_disallowed(self):
event = self.createWechatEvent()
......@@ -530,7 +594,7 @@ return addToDate(DateTime(), to_add={'day': -1, 'second': -1}).toZone('UTC'), 'f
'Aborting refused wechat payment.',
payment.workflow_history['accounting_workflow'][-1]['comment'])
class TestSlapOSWechatBase_getWechatServiceRelativeUrl(SlapOSTestCaseMixinWithAbort):
class TestSlapOSWechatBase_getWechatServiceRelativeUrl(TestSlapOSWechatMixin):
def test_getWechatServiceRelativeUrl_REQUEST_disallowed(self):
self.assertRaises(
Unauthorized,
......@@ -538,20 +602,18 @@ class TestSlapOSWechatBase_getWechatServiceRelativeUrl(SlapOSTestCaseMixinWithAb
REQUEST={})
def test_getWechatServiceRelativeUrl_default_result(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
self.tic()
result = self.portal.Base_getWechatServiceRelativeUrl()
self.assertEqual(result, 'portal_secure_payments/slapos_wechat_test')
self.assertEqual(result, self.wechat_secure_payment.getRelativeUrl())
def test_getWechatServiceRelativeUrl_not_found(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("disabled")
self.wechat_secure_payment.setReference("disabled")
self.tic()
result = self.portal.Base_getWechatServiceRelativeUrl()
self.assertEqual(result, None)
class TestSlapOSWechatPaymentTransaction_redirectToManualWechatPayment(
SlapOSTestCaseMixinWithAbort):
TestSlapOSWechatMixin):
def _simulatePaymentTransaction_getVADSUrlDict(self):
script_name = 'PaymentTransaction_getVADSUrlDict'
......@@ -588,10 +650,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self._dropPaymentTransaction_getVADSUrlDict()
def test_PaymentTransaction_redirectToManualWechatPayment_redirect(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
destination_section_value=person,
destination_project_value=project
......@@ -639,7 +700,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
transaction.abort()
def test_PaymentTransaction_redirectToManualWechatPayment_redirect_with_website(self):
self.portal.portal_secure_payments.slapos_wechat_test.setReference("PSERV-Wechat-Test")
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
......@@ -688,7 +748,7 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
def test_PaymentTransaction_redirectToManualWechatPayment_already_registered(self):
project = self.addProject()
person = self.makePerson(project)
invoice = self.createStoppedSaleInvoiceTransaction(
invoice = self.createStoppedSaleInvoiceTransaction(
payment_mode="wechat",
destination_section_value=person,
destination_project_value=project
......
......@@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from erp5.component.test.testSlapOSWechatSkins import TestSlapOSWechatMixin
from erp5.component.document.WechatService import WechatService
......@@ -28,7 +28,7 @@ import transaction
HARDCODED_PRICE = 99.6
class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
class TestSlapOSWechatInterfaceWorkflow(TestSlapOSWechatMixin):
def _simulatePaymentTransaction_getTotalPayablePrice(self):
script_name = 'PaymentTransaction_getTotalPayablePrice'
......@@ -69,7 +69,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
)
event.edit(
destination_value=payment,
source="portal_secure_payments/slapos_wechat_test",
source=self.wechat_secure_payment.getRelativeUrl(),
)
self.assertRaises(AttributeError, event.generateManualPaymentPage)
......@@ -81,7 +81,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
)
event.edit(
destination_value=payment,
source="portal_secure_payments/slapos_wechat_test",
source=self.wechat_secure_payment.getRelativeUrl(),
)
payment_transaction_id = payment.getId().encode('utf-8')
......@@ -156,7 +156,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
self.assertRaises(AttributeError, event.updateStatus)
def mockQueryWechatOrderStatus(self, method_to_call, expected_args, result_dict):
payment_service = self.portal.portal_secure_payments.slapos_wechat_test
payment_service = self.wechat_secure_payment
def mock_QueryWechatOrderStatus(arg1):
self.assertEqual(arg1, expected_args)
return result_dict
......@@ -189,7 +189,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by W
payment = self.createPaymentTransaction()
event.edit(
destination_value=payment,
source="portal_secure_payments/slapos_wechat_test",
source=self.wechat_secure_payment.getRelativeUrl(),
)
_, transaction_id = \
payment.PaymentTransaction_generateWechatId()
......
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSWechatWorkflow</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
portal_integrations/slapos_wechat_test_integration
portal_integrations/slapos_wechat_test_integration/**
portal_secure_payments/slapos_wechat_test
portal_secure_payments/slapos_wechat_test/**
sale_trade_condition_module/wechat_sale_trade_condition
\ No newline at end of file
image_module/wechat**
portal_alarms/slapos_wechat_update_started_payment
portal_integrations/slapos_wechat_test_integration
portal_integrations/slapos_wechat_test_integration/Causality
portal_integrations/slapos_wechat_test_integration/Resource
portal_integrations/slapos_wechat_test_integration/Resource/**
portal_integrations/slapos_wechat_test_integration/SourceProject
portal_secure_payments/slapos_wechat_test
portal_secure_payments/slapos_wechat_test/**
\ No newline at end of file
portal_alarms/slapos_wechat_update_started_payment
\ No newline at end of file
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