Commit 26c4d8f1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_wechat: Price isn't a negative value

parent e725b1e7
...@@ -22,7 +22,6 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort ...@@ -22,7 +22,6 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
import difflib
import transaction import transaction
HARDCODED_PRICE = 99.6 HARDCODED_PRICE = 99.6
...@@ -84,6 +83,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort): ...@@ -84,6 +83,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
) )
payment_transaction_id = payment.getId().encode('utf-8') payment_transaction_id = payment.getId().encode('utf-8')
total_fee = int(HARDCODED_PRICE * 100)
before_date = DateTime() before_date = DateTime()
self._simulatePaymentTransaction_getTotalPayablePrice() self._simulatePaymentTransaction_getTotalPayablePrice()
try: try:
...@@ -112,13 +112,16 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort): ...@@ -112,13 +112,16 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
# Event state # Event state
self.assertEqual(event.getValidationState(), "acknowledged") self.assertEqual(event.getValidationState(), "acknowledged")
expected_url = "http://example.org/#wechat_payment?trade_no=%s&price=1&payment_url=" % (payment_transaction_id) expected_url = "http://example.org/#wechat_payment?trade_no=%s&price=%s&payment_url=" %\
(payment_transaction_id, total_fee)
# Event message state # Event message state
event_message_list = event.contentValues(portal_type="Wechat Event Message") event_message_list = event.contentValues(portal_type="Wechat Event Message")
self.assertEqual(len(event_message_list), 1) self.assertEqual(len(event_message_list), 1)
message = event_message_list[0] message = event_message_list[0]
self.assertEqual(message.getTitle(), 'Shown Page') self.assertEqual(message.getTitle(), 'Shown Page')
self.assertTrue(expected_url in message.getTextContent()) self.assertTrue(expected_url in message.getTextContent(),
"%s not in %s" % (expected_url, message.getTextContent()))
transaction.abort() transaction.abort()
......
...@@ -45,9 +45,7 @@ ...@@ -45,9 +45,7 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple/>
<string>W: 25, 0: Unused import difflib (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -11,7 +11,7 @@ if transaction_id is None: ...@@ -11,7 +11,7 @@ if transaction_id is None:
wechat_dict = { wechat_dict = {
'out_trade_no': payment_transaction.getId().encode('utf-8'), 'out_trade_no': payment_transaction.getId().encode('utf-8'),
'total_fee': str(int(round((payment_transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))), 'total_fee': str(int(round((payment_transaction.PaymentTransaction_getTotalPayablePrice() * 100), 0))),
'fee_type': payment_transaction.getResourceValue().Currency_getIntegrationMapping(), 'fee_type': payment_transaction.getResourceValue().Currency_getIntegrationMapping(),
'body': "Rapid Space Virtual Machine".encode('utf-8') 'body': "Rapid Space Virtual Machine".encode('utf-8')
} }
......
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