mirror of
https://github.com/valitydev/fistful-server.git
synced 2024-11-06 10:45:21 +00:00
update wallet handler tests
This commit is contained in:
parent
c363a52a7a
commit
64aa94258b
@ -11,9 +11,11 @@
|
||||
-export([init_per_testcase/2]).
|
||||
-export([end_per_testcase/2]).
|
||||
|
||||
-export([create_wallet_ok/1]).
|
||||
-export([create_wallet_identity_fails/1]).
|
||||
-export([create_wallet_currency_fails/1]).
|
||||
-export([create_ok/1]).
|
||||
-export([create_error_identity_not_found/1]).
|
||||
-export([create_error_currency_not_found/1]).
|
||||
-export([create_error_party_blocked/1]).
|
||||
-export([create_error_party_suspended/1]).
|
||||
|
||||
-type config() :: ct_helper:config().
|
||||
-type test_case_name() :: ct_helper:test_case_name().
|
||||
@ -30,9 +32,11 @@ all() ->
|
||||
groups() ->
|
||||
[
|
||||
{default, [parallel], [
|
||||
create_wallet_ok,
|
||||
create_wallet_identity_fails,
|
||||
create_wallet_currency_fails
|
||||
create_ok,
|
||||
create_error_identity_not_found,
|
||||
create_error_currency_not_found,
|
||||
create_error_party_blocked,
|
||||
create_error_party_suspended
|
||||
]}
|
||||
].
|
||||
|
||||
@ -74,19 +78,20 @@ init_per_testcase(Name, C) ->
|
||||
end_per_testcase(_Name, _C) ->
|
||||
ok = ff_woody_ctx:unset().
|
||||
|
||||
-spec create_ok(config()) -> test_return().
|
||||
-spec create_error_identity_not_found(config()) -> test_return().
|
||||
-spec create_error_currency_not_found(config()) -> test_return().
|
||||
-spec create_error_party_blocked(config()) -> test_return().
|
||||
-spec create_error_party_suspended(config()) -> test_return().
|
||||
|
||||
-spec create_wallet_ok(config()) -> test_return().
|
||||
-spec create_wallet_identity_fails(config()) -> test_return().
|
||||
-spec create_wallet_currency_fails(config()) -> test_return().
|
||||
|
||||
create_wallet_ok(C) ->
|
||||
Party = create_party(C),
|
||||
Currency = <<"RUB">>,
|
||||
create_ok(C) ->
|
||||
Party = create_party(C),
|
||||
Currency = <<"RUB">>,
|
||||
WalletName = <<"Valet">>,
|
||||
ID = genlib:unique(),
|
||||
ID = genlib:unique(),
|
||||
ExternalId = genlib:unique(),
|
||||
IdentityID = create_person_identity(Party, C),
|
||||
Ctx = #{<<"TEST_NS">> => {obj, #{ {str, <<"KEY">>} => {b, true} }}},
|
||||
Ctx = #{<<"TEST_NS">> => {obj, #{ {str, <<"KEY">>} => {b, true}}}},
|
||||
Params = #wlt_WalletParams{
|
||||
id = ID,
|
||||
name = WalletName,
|
||||
@ -99,22 +104,22 @@ create_wallet_ok(C) ->
|
||||
},
|
||||
{ok, Wallet} = call_service('Create', [Params]),
|
||||
{ok, Wallet2} = call_service('Get', [ID]),
|
||||
Wallet = Wallet2,
|
||||
WalletName = Wallet2#wlt_Wallet.name,
|
||||
unblocked = Wallet2#wlt_Wallet.blocking,
|
||||
ExternalId = Wallet2#wlt_Wallet.external_id,
|
||||
Ctx = Wallet2#wlt_Wallet.context,
|
||||
Account = Wallet2#wlt_Wallet.account,
|
||||
IdentityID = Account#account_Account.identity,
|
||||
CurrencyRef = Account#account_Account.currency,
|
||||
Currency = CurrencyRef#'CurrencyRef'.symbolic_code.
|
||||
Wallet = Wallet2,
|
||||
WalletName = Wallet2#wlt_Wallet.name,
|
||||
unblocked = Wallet2#wlt_Wallet.blocking,
|
||||
ExternalId = Wallet2#wlt_Wallet.external_id,
|
||||
Ctx = Wallet2#wlt_Wallet.context,
|
||||
Account = Wallet2#wlt_Wallet.account,
|
||||
IdentityID = Account#account_Account.identity,
|
||||
CurrencyRef = Account#account_Account.currency,
|
||||
Currency = CurrencyRef#'CurrencyRef'.symbolic_code.
|
||||
|
||||
create_wallet_identity_fails(_C) ->
|
||||
Currency = <<"RUB">>,
|
||||
ID = genlib:unique(),
|
||||
create_error_identity_not_found(_C) ->
|
||||
Currency = <<"RUB">>,
|
||||
ID = genlib:unique(),
|
||||
ExternalId = genlib:unique(),
|
||||
IdentityID = genlib:unique(),
|
||||
Params = #wlt_WalletParams{
|
||||
Params = #wlt_WalletParams{
|
||||
id = ID,
|
||||
name = <<"Valet">>,
|
||||
external_id = ExternalId,
|
||||
@ -125,12 +130,12 @@ create_wallet_identity_fails(_C) ->
|
||||
},
|
||||
{exception, {fistful_IdentityNotFound}} = call_service('Create', [Params]).
|
||||
|
||||
create_wallet_currency_fails(C) ->
|
||||
Party = create_party(C),
|
||||
Currency = <<"RBK.MONEY">>,
|
||||
ID = genlib:unique(),
|
||||
create_error_currency_not_found(C) ->
|
||||
Party = create_party(C),
|
||||
Currency = <<"RBK.MONEY">>,
|
||||
ID = genlib:unique(),
|
||||
IdentityID = create_person_identity(Party, C),
|
||||
Params = #wlt_WalletParams{
|
||||
Params = #wlt_WalletParams{
|
||||
id = ID,
|
||||
name = <<"Valet">>,
|
||||
account_params = #account_AccountParams{
|
||||
@ -141,6 +146,40 @@ create_wallet_currency_fails(C) ->
|
||||
},
|
||||
{exception, {fistful_CurrencyNotFound}} = call_service('Create', [Params]).
|
||||
|
||||
create_error_party_blocked(C) ->
|
||||
Party = create_party(C),
|
||||
Currency = <<"RBK.MONEY">>,
|
||||
ID = genlib:unique(),
|
||||
IdentityID = create_person_identity(Party, C),
|
||||
ok = block_party(Party, C),
|
||||
Params = #wlt_WalletParams{
|
||||
id = ID,
|
||||
name = <<"Valet">>,
|
||||
account_params = #account_AccountParams{
|
||||
identity_id = IdentityID,
|
||||
symbolic_code = Currency
|
||||
}
|
||||
|
||||
},
|
||||
{exception, {fistful_PartyInaccessible}} = call_service('Create', [Params]).
|
||||
|
||||
create_error_party_suspended(C) ->
|
||||
Party = create_party(C),
|
||||
Currency = <<"RBK.MONEY">>,
|
||||
ID = genlib:unique(),
|
||||
IdentityID = create_person_identity(Party, C),
|
||||
ok = suspend_party(Party, C),
|
||||
Params = #wlt_WalletParams{
|
||||
id = ID,
|
||||
name = <<"Valet">>,
|
||||
account_params = #account_AccountParams{
|
||||
identity_id = IdentityID,
|
||||
symbolic_code = Currency
|
||||
}
|
||||
|
||||
},
|
||||
{exception, {fistful_PartyInaccessible}} = call_service('Create', [Params]).
|
||||
|
||||
%%-----------
|
||||
%% Internal
|
||||
%%-----------
|
||||
@ -169,4 +208,24 @@ create_identity(Party, ProviderID, ClassID, _C) ->
|
||||
#{party => Party, provider => ProviderID, class => ClassID},
|
||||
ff_ctx:new()
|
||||
),
|
||||
ID.
|
||||
ID.
|
||||
|
||||
construct_userinfo() ->
|
||||
#payproc_UserInfo{id = <<"fistful">>, type = construct_usertype()}.
|
||||
|
||||
construct_usertype() ->
|
||||
{service_user, #payproc_ServiceUser{}}.
|
||||
|
||||
suspend_party(Party, C) ->
|
||||
Service = {dmsl_payment_processing_thrift, 'PartyManagement'},
|
||||
Args = [construct_userinfo(), Party],
|
||||
Request = {Service, 'Suspend', Args},
|
||||
_ = ff_woody_client:call(partymgmt, Request, ct_helper:get_woody_ctx(C)),
|
||||
ok.
|
||||
|
||||
block_party(Party, C) ->
|
||||
Service = {dmsl_payment_processing_thrift, 'PartyManagement'},
|
||||
Args = [construct_userinfo(), Party, <<"BECAUSE">>],
|
||||
Request = {Service, 'Block', Args},
|
||||
_ = ff_woody_client:call(partymgmt, Request, ct_helper:get_woody_ctx(C)),
|
||||
ok.
|
||||
|
Loading…
Reference in New Issue
Block a user