Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Eric Zheng
slapos.core
Commits
b9e4820b
Commit
b9e4820b
authored
Dec 17, 2019
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_wechat: Fix up test
parent
ade9c891
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
126 deletions
+30
-126
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatWorkflow.py
...m/portal_components/test.erp5.testSlapOSWechatWorkflow.py
+27
-63
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatWorkflow.xml
.../portal_components/test.erp5.testSlapOSWechatWorkflow.xml
+3
-1
master/bt5/slapos_wechat/WorkflowTemplateItem/portal_workflow/wechat_interface_workflow/transitions/register_payzen.xml
...wechat_interface_workflow/transitions/register_payzen.xml
+0
-62
No files found.
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatWorkflow.py
View file @
b9e4820b
...
...
@@ -23,6 +23,7 @@ from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from
DateTime
import
DateTime
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
import
difflib
import
transaction
HARDCODED_PRICE
=
99.6
...
...
@@ -82,12 +83,21 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
source
=
"portal_secure_payments/slapos_wechat_test"
,
)
payment_transaction_id
=
payment
.
getId
().
encode
(
'utf-8'
)
before_date
=
DateTime
()
self
.
_simulatePaymentTransaction_getTotalPayablePrice
()
try
:
event
.
generateManualPaymentPage
()
def
mock_absolute_url
():
return
"http://example.org"
original_method
=
self
.
portal
.
absolute_url
self
.
portal
.
absolute_url
=
mock_absolute_url
try
:
event
.
generateManualPaymentPage
()
finally
:
self
.
portal
.
absolute_url
=
original_method
finally
:
self
.
_dropPaymentTransaction_getTotalPayablePrice
()
after_date
=
DateTime
()
# Payment start date is modified
...
...
@@ -102,58 +112,16 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
# Event state
self
.
assertEqual
(
event
.
getValidationState
(),
"acknowledged"
)
data_dict
=
{
'out_trade_no'
:
payment
.
getId
().
encode
(
'utf-8'
),
'total_fee'
:
1
,
#str(int(round((payment_transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),
'fee_type'
:
'CNY'
,
'body'
:
"Rapid Space Virtual Machine"
.
encode
(
'utf-8'
)
}
# Calculate the signature...
self
.
portal
.
portal_secure_payments
.
slapos_wechat_test
.
_getFieldList
(
data_dict
)
data_dict
[
'action'
]
=
'https://secure.wechat.eu/vads-payment/'
expected_html_page
=
\
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w'
\
'3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\
n
<html xmlns="http://www.w3.or'
\
'g/1999/xhtml" xml:lang="en" lang="en">
\
n
<head>
\
n
<meta http-equiv="Co'
\
'ntent-Type" content="text/html; charset=utf-8" />
\
n
<meta http-equiv='
\
'"Content-Script-Type" content="text/javascript" />
\
n
<meta http-equiv'
\
'="Content-Style-Type" content="text/css" />
\
n
<title>title</title>
\
n
<'
\
'/head>
\
n
<body onload="document.payment.submit();">
\
n
<form method="POST'
\
'" id="payment" name="payment"
\
n
action="%(action)s">
\
n
\
n
<input '
\
'type="hidden" name="vads_url_return"
\
n
value="'
\
'%(vads_url_return)s">
\
n
\
n
\
n
<input type="hidden" name="vads_site_id" '
\
'value="%(vads_site_id)s">
\
n
\
n
\
n
<input type="hidden" name="vads_url_e'
\
'rror"
\
n
value="%(vads_url_error)s">
\
n
\
n
\
n
<input type="hidden'
\
'" name="vads_trans_id" value="%(vads_trans_id)s">
\
n
\
n
\
n
<input type="'
\
'hidden" name="vads_action_mode"
\
n
value="INTERACTIVE">
\
n
\
n
\
n
'
\
'<input type="hidden" name="vads_url_success"
\
n
value="'
\
'%(vads_url_success)s">
\
n
\
n
\
n
<input type="hidden" name="vads_url_refe'
\
'rral"
\
n
value="%(vads_url_referral)s">
\
n
\
n
\
n
<input type="hid'
\
'den" name="vads_page_action"
\
n
value="PAYMENT">
\
n
\
n
\
n
<input '
\
'type="hidden" name="vads_trans_date"
\
n
value="'
\
'%(vads_trans_date)s">
\
n
\
n
\
n
<input type="hidden" name="vads_url_refus'
\
'ed"
\
n
value="%(vads_url_refused)s">
\
n
\
n
\
n
<input type="hidden'
\
'" name="vads_url_cancel"
\
n
value="%(vads_url_cancel)s">
\
n
\
n
\
n
'
\
' <input type="hidden" name="vads_ctx_mode" value="TEST">
\
n
\
n
\
n
<input '
\
'type="hidden" name="vads_payment_config"
\
n
value="SINGLE">
\
n
\
n
'
\
'
\
n
<input type="hidden" name="vads_contrib" value="ERP5">
\
n
\
n
\
n
<inp'
\
'ut type="hidden" name="signature"
\
n
value="%(signature)s">
\
n
\
n
'
\
'
\
n
<input type="hidden" name="vads_language" value="%(vads_language)s">
\
n
\
n
\
n
<inpu'
\
't type="hidden" name="vads_currency" value="%(vads_currency)s">
\
n
\
n
\
n
'
\
' <input type="hidden" name="vads_amount" value="%(vads_amount)s">
\
n
\
n
\
n
'
\
' <input type="hidden" name="vads_version" value="V2">
\
n
\
n
<input type="s'
\
'ubmit" value="Click to pay">
\
n
</form>
\
n
</body>
\
n
</html>'
%
data_dict
expected_url
=
"http://example.org/#wechat_payment?trade_no=%s&price=1&payment_url="
%
(
payment_transaction_id
)
# Event message state
event_message_list
=
event
.
contentValues
(
portal_type
=
"Wechat Event Message"
)
self
.
assertEqual
(
len
(
event_message_list
),
1
)
message
=
event_message_list
[
0
]
self
.
assertEqual
(
message
.
getTitle
(),
'Shown Page'
)
self
.
assert
Equal
(
message
.
getTextContent
(),
expected_html_page
,
'
\
n
'
.
join
([
q
for
q
in
difflib
.
unified_diff
(
expected_html_page
.
split
(
'
\
n
'
),
message
.
getTextContent
().
split
(
'
\
n
'
))])
)
self
.
assert
True
(
expected_url
in
message
.
getTextContent
())
transaction
.
abort
(
)
def
test_updateStatus_noAccountingTransaction
(
self
):
event
=
self
.
createWechatEvent
()
...
...
@@ -176,17 +144,16 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
_
,
_
=
payment
.
PaymentTransaction_generateWechatId
()
self
.
assertRaises
(
AttributeError
,
event
.
updateStatus
)
def
mock
SoapGetInfo
(
self
,
method_to_call
,
expected_args
,
result_tuple
):
def
mock
QueryWechatOrderStatus
(
self
,
method_to_call
,
expected_args
,
result_dict
):
payment_service
=
self
.
portal
.
portal_secure_payments
.
slapos_wechat_test
def
mocksoad_getInfo
(
arg1
,
arg2
):
self
.
assertEqual
(
arg1
,
expected_args
[
0
])
self
.
assertEqual
(
arg2
,
expected_args
[
1
])
return
result_tuple
setattr
(
payment_service
,
'soap_getInfo'
,
mocksoad_getInfo
)
def
mock_QueryWechatOrderStatus
(
arg1
):
self
.
assertEqual
(
arg1
,
expected_args
)
return
result_dict
setattr
(
payment_service
,
'queryWechatOrderStatus'
,
mock_QueryWechatOrderStatus
)
try
:
return
method_to_call
()
finally
:
del
payment_service
.
soap_getInfo
del
payment_service
.
queryWechatOrderStatus
def
_simulateWechatEvent_processUpdate
(
self
):
script_name
=
'WechatEvent_processUpdate'
...
...
@@ -213,20 +180,17 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by W
destination_value
=
payment
,
source
=
"portal_secure_payments/slapos_wechat_test"
,
)
transaction_date
,
transaction_id
=
\
_
,
transaction_id
=
\
payment
.
PaymentTransaction_generateWechatId
()
mocked_data_kw
=
'mocked_data_kw'
mocked_signature
=
'mocked_signature'
mocked_sent_text
=
'mocked_sent_text'
mocked_received_text
=
'mocked_received_text'
self
.
_simulateWechatEvent_processUpdate
()
try
:
self
.
mock
SoapGetInfo
(
self
.
mock
QueryWechatOrderStatus
(
event
.
updateStatus
,
(
transaction_date
.
toZone
(
'UTC'
).
asdatetime
(),
transaction_id
)
,
(
mocked_data_kw
,
mocked_signature
,
mocked_sent_text
,
mocked_received_text
),
{
'out_trade_no'
:
transaction_id
}
,
mocked_data_kw
)
finally
:
self
.
_dropWechatEvent_processUpdate
()
...
...
@@ -236,13 +200,13 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by W
sent_message
=
[
x
for
x
in
event_message_list
\
if
x
.
getTitle
()
==
'Query Order Status'
][
0
]
self
.
assertEqual
(
sent_message
.
getTextContent
(),
mocked_sent_text
)
self
.
assertEqual
(
sent_message
.
getTextContent
(),
str
({
'out_trade_no'
:
transaction_id
})
)
received_message
=
[
x
for
x
in
event_message_list
\
if
x
.
getTitle
()
==
'Received Order Status'
][
0
]
self
.
assertEqual
(
received_message
.
getPredecessor
(),
sent_message
.
getRelativeUrl
())
self
.
assertEqual
(
received_message
.
getTextContent
(),
mocked_
received_text
)
self
.
assertEqual
(
received_message
.
getTextContent
(),
mocked_
data_kw
)
self
.
assertEqual
(
'Visited by WechatEvent_processUpdate'
,
...
...
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatWorkflow.xml
View file @
b9e4820b
...
...
@@ -45,7 +45,9 @@
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
<tuple>
<string>
W: 25, 0: Unused import difflib (unused-import)
</string>
</tuple>
</value>
</item>
<item>
...
...
master/bt5/slapos_wechat/WorkflowTemplateItem/portal_workflow/wechat_interface_workflow/transitions/register_payzen.xml
deleted
100644 → 0
View file @
ade9c891
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"TransitionDefinition"
module=
"Products.DCWorkflow.Transitions"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
actbox_category
</string>
</key>
<value>
<string>
workflow
</string>
</value>
</item>
<item>
<key>
<string>
actbox_icon
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
actbox_name
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
actbox_url
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
after_script_name
</string>
</key>
<value>
<string>
WechatEvent_registerWechat
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
guard
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
register_payzen
</string>
</value>
</item>
<item>
<key>
<string>
new_state_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
script_name
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
trigger_type
</string>
</key>
<value>
<int>
2
</int>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment