Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Kunto
/
backoffice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d0ce9351
authored
Jul 24, 2019
by
Solo Group
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
test_odeo
1 parent
ebf37c00
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
39 deletions
src/agratek/api/merchant/scripts/test_odeo.py
src/agratek/api/merchant/views/odeo.py
src/agratek/api/merchant/views/vendor.py
test_odeo.py
src/agratek/api/merchant/scripts/test_odeo.py
0 → 100644
View file @
d0ce935
File mode changed
src/agratek/api/merchant/views/odeo.py
View file @
d0ce935
This diff is collapsed.
Click to expand it.
src/agratek/api/merchant/views/vendor.py
View file @
d0ce935
...
...
@@ -52,7 +52,7 @@ def build_request(typ, values):
.
filter
(
PartnerProduk
.
partner_id
==
vendor_id
,
PartnerProduk
.
produk_id
==
produk_id
)
.
first
()
if
not
vendor_product
:
return
dict
(
error
=
'Data Tidak Ditemukan'
)
return
dict
(
data
=
dict
(
error
=
'Data Tidak Ditemukan'
)
)
row
=
None
if
"trx_id"
in
values
and
values
[
'trx_id'
]:
...
...
@@ -63,36 +63,48 @@ def build_request(typ, values):
cls_module
=
modules
.
Vendor
(
vendor_product
,
bill_no
,
customer_id
,
cust_trx_id
,
row
)
if
typ
==
'inquiry'
:
result
=
hasattr
(
cls_module
,
typ
)
and
cls_module
.
inquiry
()
or
None
if
result
:
result
[
"f_request"
]
=
cls_module
.
request
result
[
"f_response"
]
=
cls_module
.
response
return
result
elif
typ
==
'payment'
:
result
=
cls_module
.
payment
()
if
result
:
result
[
"f_request"
]
=
cls_module
.
request
result
[
"f_response"
]
=
cls_module
.
response
return
result
elif
typ
==
'advice'
:
result
=
hasattr
(
cls_module
,
typ
)
and
cls_module
.
advice
()
or
None
if
result
:
cls
=
hasattr
(
cls_module
,
typ
)
and
getattr
(
cls_module
,
typ
)
or
None
if
cls
:
data
=
cls
()
result
=
dict
(
data
=
data
)
result
[
"f_request"
]
=
cls_module
.
request
result
[
"f_response"
]
=
cls_module
.
response
result
[
"url"
]
=
cls_module
.
url
else
:
result
=
dict
(
data
=
dict
(
error
=
'Fungsi
%
s tidak ada'
%
typ
,
code
=
9999
))
return
result
elif
typ
==
'info'
:
result
=
hasattr
(
cls_module
,
typ
)
and
cls_module
.
info
()
or
None
if
result
:
result
[
"f_request"
]
=
cls_module
.
request
result
[
"f_response"
]
=
cls_module
.
reesponse
return
result
else
:
return
dict
(
error
=
'Function
%
s tidak ditemukan'
%
typ
)
# if typ=='inquiry':
# data = cls_module.inquiry()
# result = dict(data=data)
# result["f_request"] = cls_module.request
# result["f_response"] = cls_module.response
# return result
#
# elif typ=='payment':
# data = cls_module.payment()
# result = dict(data=data)
# result["f_request"] = cls_module.request
# result["f_response"] = cls_module.response
# return result
#
# elif typ == 'advice':
# data = hasattr(cls_module, typ) and cls_module.advice() or None
# result = dict(data=data)
# result["f_request"] = cls_module.request
# result["f_response"] = cls_module.response
# return result
#
# elif typ == 'info':
# data = hasattr(cls_module, typ) and cls_module.info() or None
# result = dict(data=data)
# result["f_request"] = cls_module.request
# result["f_response"] = cls_module.reesponse
# return result
# else:
# return dict(error='Function %s tidak ditemukan' % typ)
@colander.deferred
...
...
@@ -284,7 +296,9 @@ class ViewHome(BaseView):
values
=
dict
(
c
.
items
())
# if 'trx_id' not in values or not values['trx_id']:
# values['trx_id'] = get_random_number(10)
result
=
[]
# result = build_request('inquiry', values)
#
result
=
None
if
'inquiry'
in
request
.
POST
:
result
=
build_request
(
'inquiry'
,
values
)
elif
'payment'
in
request
.
POST
:
...
...
@@ -296,16 +310,23 @@ class ViewHome(BaseView):
elif
'info'
in
request
.
POST
:
result
=
build_request
(
'info'
,
values
)
if
not
result
:
session
.
flash
(
'Data Tidak Ditemukan'
,
'error'
)
#
if not result:
#
session.flash('Data Tidak Ditemukan', 'error')
if
result
and
'error'
in
result
:
session
.
flash
(
result
[
'error'
],
'error'
)
if
result
and
'data'
in
result
:
data
=
result
[
'data'
]
values
[
'f_request'
]
=
'f_request'
in
result
\
and
json
.
dumps
(
result
[
'f_request'
],
indent
=
4
)
or
''
values
[
'f_response'
]
=
'f_response'
in
result
\
and
json
.
dumps
(
result
[
'f_response'
],
indent
=
4
)
or
''
else
:
values
[
'result'
]
=
json
.
dumps
(
result
,
indent
=
4
)
values
[
'ref_no'
]
=
'ref_no'
in
result
and
result
[
"ref_no"
]
or
None
values
[
'trx_id'
]
=
'trx_id'
in
result
and
result
[
'trx_id'
]
or
None
values
[
'f_result'
]
=
'data'
in
result
\
and
json
.
dumps
(
result
[
'data'
],
indent
=
4
)
or
''
values
[
'ref_no'
]
=
'ref_no'
in
data
and
data
[
"ref_no"
]
or
""
values
[
'trx_id'
]
=
'trx_id'
in
data
and
data
[
'trx_id'
]
or
""
values
[
'vend_trx'
]
=
'vend_trx'
in
data
and
data
[
'vend_trx'
]
or
""
if
'error'
in
data
and
data
[
'error'
]:
session
.
flash
(
data
[
'error'
],
'error'
)
form
.
render
(
values
)
return
dict
(
form
=
form
,
params
=
form_params_view
)
...
...
@@ -314,7 +335,7 @@ class ViewHome(BaseView):
class
VendorClass
(
object
):
def
__init__
(
self
,
vendor_produk
,
bill_no
,
customer_id
=
None
,
cust_trx
_id
=
None
,
row
=
None
):
cust_trx
=
None
,
row
=
None
):
"""
:param cid:
merupakan customer id seperti MSN dan atu id pelanggaan
...
...
@@ -325,11 +346,12 @@ class VendorClass(object):
self
.
produk_id
=
vendor_produk
.
produk_id
self
.
bill_no
=
bill_no
self
.
customer_id
=
customer_id
self
.
cust_trx_id
=
cust_trx_id
self
.
cust_trx
=
cust_trx
self
.
vend_trx
=
None
self
.
response
=
None
self
.
request
=
None
self
.
partner_log
=
row
self
.
partner_log_id
=
None
self
.
partner_log_id
=
row
and
row
.
id
or
None
self
.
v_produk_kd
=
vendor_produk
.
kode
self
.
kategori
=
vendor_produk
.
produk
.
kategori
.
nama
...
...
@@ -340,7 +362,8 @@ class VendorClass(object):
row
.
produk_id
=
self
.
produk_id
row
.
bill_no
=
self
.
bill_no
row
.
customer_id
=
self
.
customer_id
row
.
cust_trx_id
=
self
.
cust_trx_id
row
.
cust_trx
=
self
.
cust_trx
row
.
vend_trx
=
self
.
vend_trx
if
typ
==
'inquiry'
:
row
.
inquiry
=
dict
(
request
=
self
.
request
,
response
=
self
.
response
)
...
...
test_odeo.py
0 → 100644
View file @
d0ce935
import
unittest
import
transaction
from
agratek.api.merchant.views.vendor
import
build_request
from
opensipkd.base.models
import
Partner
from
opensipkd.pasar.models
import
PartnerProduk
,
Produk
from
pyramid.paster
import
get_appsettings
from
pyramid_rpc.jsonrpc
import
JsonRpcError
from
pyramid
import
testing
class
TestOdeo
(
unittest
.
TestCase
):
def
setUp
(
self
):
settings
=
get_appsettings
(
'test.ini'
,
name
=
'main'
)
self
.
config
=
testing
.
setUp
(
settings
=
settings
)
# self.config.include('..models')
# self.config.include('..routes')
#session_factory = self.config.registry['dbsession_factory']
#self.session = get_tm_session(session_factory, transaction.manager)
#
# self.config = testing.setUp()
# from pyramid.paster import get_appsettings
from
opensipkd.base
import
main
app
=
main
({},
**
settings
)
def
test_vendor
(
self
):
"""
Test that it can sum a list of integers
"""
produk_kd
=
'TS-5'
bill_no
=
'081311045668'
partner_kd
=
'ODEO'
vendor
=
Partner
.
query_kode
(
partner_kd
)
.
first
()
produk
=
Produk
.
query_kode
(
produk_kd
)
.
first
()
if
not
vendor
or
not
produk
:
raise
JsonRpcError
(
message
=
"Vendor Not Found"
)
values
=
dict
(
vendor_id
=
vendor
.
id
,
produk_id
=
produk
.
id
,
destination
=
bill_no
)
result
=
build_request
(
'payment'
,
values
)
for
r
in
result
:
print
(
r
,
":"
,
result
[
r
])
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment