-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathroyalty_settlement_test.rb
More file actions
68 lines (57 loc) · 2.07 KB
/
Copy pathroyalty_settlement_test.rb
File metadata and controls
68 lines (57 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require File.expand_path('../test_assistant', __FILE__)
module Pingpp
class RoyaltySettlementTest < Test::Unit::TestCase
# 创建分润结算
should "return a royalty_settlement object when passed correct params" do
params = {
# 分润发起方所在的 App ID required|string
:payer_app => get_payer_app,
# 分润的方式 required|string,null; 余额 balance 或渠道名称 [alipay, wx_pub, unionpay, ...]
:method => "alipay",
# 分润创建时间 optional|hash
:created => {
:gte => 1504875000,
:lt => 1504885000
},
}
begin
o = Pingpp::RoyaltySettlement.create(params)
assert o.kind_of?(Pingpp::RoyaltySettlement)
rescue => e
assert e.kind_of?(Pingpp::InvalidRequestError)
assert e.message.include?("无有效")
end
end
# 查询分润结算对象
should "return an existed royalty_settlement object when passed a correct id" do
o = Pingpp::RoyaltySettlement.retrieve(existed_royalty_settlement_id)
assert o.kind_of?(Pingpp::RoyaltySettlement)
end
# 更新/取消分润结算对象
should "return an updated royalty_settlement object when passed a correct id" do
begin
o = Pingpp::RoyaltySettlement.update(
existed_royalty_settlement_id,
{
# 更新状态 required|string; canceled: 取消结算, pending: 确认结算
:status => 'canceled'
}
)
assert o.kind_of?(Pingpp::RoyaltySettlement)
rescue => e
assert e.kind_of?(Pingpp::InvalidRequestError) || e.kind_of?(Pingpp::ChannelError)
assert e.message.include?("状态错误")
end
end
# 查询分润结算对象列表
should "return a list object of royalty_settlement" do
o = Pingpp::RoyaltySettlement.list(
{ :per_page => 3, :page => 1, :payer_app => get_payer_app }
)
assert o.kind_of?(Pingpp::ListObject)
if o.data.count > 0
assert o.data[0].kind_of?(Pingpp::RoyaltySettlement)
end
end
end
end