update wallet handler tests

This commit is contained in:
Roman Pushkov 2019-09-17 10:48:36 +03:00
parent c363a52a7a
commit 64aa94258b

View File

@ -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) ->
create_ok(C) ->
Party = create_party(C),
Currency = <<"RUB">>,
WalletName = <<"Valet">>,
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,
@ -109,7 +114,7 @@ create_wallet_ok(C) ->
CurrencyRef = Account#account_Account.currency,
Currency = CurrencyRef#'CurrencyRef'.symbolic_code.
create_wallet_identity_fails(_C) ->
create_error_identity_not_found(_C) ->
Currency = <<"RUB">>,
ID = genlib:unique(),
ExternalId = genlib:unique(),
@ -125,7 +130,7 @@ create_wallet_identity_fails(_C) ->
},
{exception, {fistful_IdentityNotFound}} = call_service('Create', [Params]).
create_wallet_currency_fails(C) ->
create_error_currency_not_found(C) ->
Party = create_party(C),
Currency = <<"RBK.MONEY">>,
ID = genlib:unique(),
@ -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
%%-----------
@ -170,3 +209,23 @@ create_identity(Party, ProviderID, ClassID, _C) ->
ff_ctx:new()
),
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.