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
0
Merge Requests
0
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
Rafael Monnerat
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
Show 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 @@
...
@@ -19,6 +19,8 @@
#
#
##############################################################################
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
erp5.component.document.WechatService
import
WechatService
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
zExceptions
import
Unauthorized
from
zExceptions
import
Unauthorized
...
@@ -660,24 +662,31 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
...
@@ -660,24 +662,31 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self
.
tic
()
self
.
tic
()
payment
=
invoice
.
SaleInvoiceTransaction_getWechatPaymentRelatedValue
()
payment
=
invoice
.
SaleInvoiceTransaction_getWechatPaymentRelatedValue
()
payment
.
setResourceValue
(
self
.
portal
.
currency_module
.
EUR
)
payment
.
setResourceValue
(
self
.
portal
.
currency_module
.
EUR
)
payment_transaction_id
=
payment
.
getId
()
self
.
tic
()
self
.
tic
()
self
.
login
(
person
.
getUserId
())
self
.
login
(
person
.
getUserId
())
self
.
_simulatePaymentTransaction_getVADSUrlDict
()
self
.
_simulatePaymentTransaction_getVADSUrlDict
()
try
:
try
:
def
mock_absolute_url
():
def
mock_absolute_url
():
return
"http://example.org"
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_method
=
self
.
portal
.
absolute_url
original_callWechatApi
=
WechatService
.
callWechatApi
self
.
portal
.
absolute_url
=
mock_absolute_url
self
.
portal
.
absolute_url
=
mock_absolute_url
WechatService
.
callWechatApi
=
callFakeWechatApi
try
:
try
:
redirected_url
=
payment
.
PaymentTransaction_redirectToManualWechatPayment
()
redirected_url
=
payment
.
PaymentTransaction_redirectToManualWechatPayment
()
finally
:
finally
:
self
.
portal
.
absolute_url
=
original_method
self
.
portal
.
absolute_url
=
original_method
WechatService
.
callWechatApi
=
original_callWechatApi
finally
:
finally
:
self
.
_dropPaymentTransaction_getVADSUrlDict
()
self
.
_dropPaymentTransaction_getVADSUrlDict
()
self
.
assertEqual
(
payment
.
PaymentTransaction_getTotalPayablePrice
(),
0
)
payment_transaction_id
=
payment
.
getId
()
expected
=
"http://example.org/#wechat_payment?trade_no=%s&price=0&payment_url=weixin://wxpay/bizpayurl?pr="
%
payment_transaction_id
expected
=
"http://example.org/#wechat_payment?trade_no=%s&price=1&payment_url=weixin://wxpay/bizpayurl?pr="
%
payment_transaction_id
self
.
assertTrue
(
redirected_url
.
startswith
(
expected
),
self
.
assertTrue
(
redirected_url
.
startswith
(
expected
),
"%s do not start with %s"
%
(
redirected_url
,
expected
))
"%s do not start with %s"
%
(
redirected_url
,
expected
))
transaction
.
abort
()
transaction
.
abort
()
...
...
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testSlapOSWechatWorkflow.py
View file @
f1d9c0ca
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
#
#
##############################################################################
##############################################################################
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
erp5.component.document.WechatService
import
WechatService
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
...
@@ -35,7 +37,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
...
@@ -35,7 +37,7 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
script_name
,
'*args, **kwargs'
,
'*args, **kwargs'
,
'# Script body
\
n
return %f'
%
HARDCODED_PRICE
)
'# Script body
\
n
return
-
%f'
%
HARDCODED_PRICE
)
def
_dropPaymentTransaction_getTotalPayablePrice
(
self
):
def
_dropPaymentTransaction_getTotalPayablePrice
(
self
):
script_name
=
'PaymentTransaction_getTotalPayablePrice'
script_name
=
'PaymentTransaction_getTotalPayablePrice'
...
@@ -89,12 +91,19 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
...
@@ -89,12 +91,19 @@ class TestSlapOSWechatInterfaceWorkflow(SlapOSTestCaseMixinWithAbort):
try
:
try
:
def
mock_absolute_url
():
def
mock_absolute_url
():
return
"http://example.org"
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_method
=
self
.
portal
.
absolute_url
original_callWechatApi
=
WechatService
.
callWechatApi
self
.
portal
.
absolute_url
=
mock_absolute_url
self
.
portal
.
absolute_url
=
mock_absolute_url
WechatService
.
callWechatApi
=
callFakeWechatApi
try
:
try
:
event
.
generateManualPaymentPage
()
event
.
generateManualPaymentPage
()
finally
:
finally
:
self
.
portal
.
absolute_url
=
original_method
self
.
portal
.
absolute_url
=
original_method
WechatService
.
callWechatApi
=
original_callWechatApi
finally
:
finally
:
self
.
_dropPaymentTransaction_getTotalPayablePrice
()
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