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
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
f1d9c0ca
Commit
f1d9c0ca
authored
Jan 15, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_wechat: Fixup Tests.
parent
5eeadcf7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatSkins.py
...Item/portal_components/test.erp5.testSlapOSWechatSkins.py
+12
-3
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatWorkflow.py
...m/portal_components/test.erp5.testSlapOSWechatWorkflow.py
+10
-1
No files found.
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatSkins.py
View file @
f1d9c0ca
...
...
@@ -19,6 +19,8 @@
#
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
erp5.component.document.WechatService
import
WechatService
from
DateTime
import
DateTime
from
zExceptions
import
Unauthorized
...
...
@@ -660,24 +662,31 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self
.
tic
()
payment
=
invoice
.
SaleInvoiceTransaction_getWechatPaymentRelatedValue
()
payment
.
setResourceValue
(
self
.
portal
.
currency_module
.
EUR
)
payment_transaction_id
=
payment
.
getId
()
self
.
tic
()
self
.
login
(
person
.
getUserId
())
self
.
_simulatePaymentTransaction_getVADSUrlDict
()
try
:
def
mock_absolute_url
():
return
"http://example.org"
def
callFakeWechatApi
(
self
,
URL
,
wechat_dict
):
return
{
"result_code"
:
'SUCCESS'
,
"code_url"
:
'weixin://wxpay/bizpayurl?pr=AAAAA'
}
original_method
=
self
.
portal
.
absolute_url
original_callWechatApi
=
WechatService
.
callWechatApi
self
.
portal
.
absolute_url
=
mock_absolute_url
WechatService
.
callWechatApi
=
callFakeWechatApi
try
:
redirected_url
=
payment
.
PaymentTransaction_redirectToManualWechatPayment
()
finally
:
self
.
portal
.
absolute_url
=
original_method
WechatService
.
callWechatApi
=
original_callWechatApi
finally
:
self
.
_dropPaymentTransaction_getVADSUrlDict
()
payment_transaction_id
=
payment
.
getId
()
expected
=
"http://example.org/#wechat_payment?trade_no=%s&price=1&payment_url=weixin://wxpay/bizpayurl?pr="
%
payment_transaction_id
self
.
assertEqual
(
payment
.
PaymentTransaction_getTotalPayablePrice
(),
0
)
expected
=
"http://example.org/#wechat_payment?trade_no=%s&price=0&payment_url=weixin://wxpay/bizpayurl?pr="
%
payment_transaction_id
self
.
assertTrue
(
redirected_url
.
startswith
(
expected
),
"%s do not start with %s"
%
(
redirected_url
,
expected
))
transaction
.
abort
()
...
...
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatWorkflow.py
View file @
f1d9c0ca
...
...
@@ -19,6 +19,8 @@
#
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
erp5.component.document.WechatService
import
WechatService
from
DateTime
import
DateTime
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
...
...
@@ -35,7 +37,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
return %f'
%
HARDCODED_PRICE
)
'# Script body
\
n
return
-
%f'
%
HARDCODED_PRICE
)
def
_dropPaymentTransaction_getTotalPayablePrice
(
self
):
script_name
=
'PaymentTransaction_getTotalPayablePrice'
...
...
@@ -89,12 +91,19 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
try
:
def
mock_absolute_url
():
return
"http://example.org"
def
callFakeWechatApi
(
self
,
URL
,
wechat_dict
):
return
{
"result_code"
:
'SUCCESS'
,
"code_url"
:
'weixin://wxpay/bizpayurl?pr=AAAAA'
}
original_method
=
self
.
portal
.
absolute_url
original_callWechatApi
=
WechatService
.
callWechatApi
self
.
portal
.
absolute_url
=
mock_absolute_url
WechatService
.
callWechatApi
=
callFakeWechatApi
try
:
event
.
generateManualPaymentPage
()
finally
:
self
.
portal
.
absolute_url
=
original_method
WechatService
.
callWechatApi
=
original_callWechatApi
finally
:
self
.
_dropPaymentTransaction_getTotalPayablePrice
()
...
...
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