Bugzilla – Attachment 176892 Details for
Bug 38931
Add endpoints for individual credits and debits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38931: Unit tests
Bug-38931-Unit-tests.patch (text/plain), 4.30 KB, created by
David Nind
on 2025-01-22 10:24:00 UTC
(
hide
)
Description:
Bug 38931: Unit tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-01-22 10:24:00 UTC
Size:
4.30 KB
patch
obsolete
>From fbe9dc56a0d0fb4c9b35abbca0e457822631f6d3 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Jan 2025 16:46:18 -0300 >Subject: [PATCH] Bug 38931: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/api/v1/patrons_accounts.t | 103 ++++++++++++++++++++++- > 1 file changed, 102 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/patrons_accounts.t b/t/db_dependent/api/v1/patrons_accounts.t >index 31d395ace6..df99f522d2 100755 >--- a/t/db_dependent/api/v1/patrons_accounts.t >+++ b/t/db_dependent/api/v1/patrons_accounts.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 7; > > use Test::Mojo; > >@@ -294,6 +294,57 @@ subtest 'add_credit() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'get_credit() tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ } >+ ); >+ my $userid = $patron->userid; >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ >+ my $patron_id = $patron->id; >+ my $credit = $patron->account->add_credit( >+ { >+ amount => 100, >+ description => "A description", >+ type => "NEW_CARD", >+ interface => 'test', >+ } >+ ); >+ my $credit_id = $credit->id; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits/$credit_id") >+ ->status_is(200) >+ ->json_is( '/account_line_id' => $credit_id ) >+ ->json_is( '/patron_id' => $patron_id ); >+ >+ $credit->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits/$credit_id") >+ ->status_is(404) >+ ->json_is( '/error_code' => 'not_found' ) >+ ->json_is( '/error' => 'Credit not found' ); >+ >+ my $deleted_patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $deleted_patron_id = $deleted_patron->id; >+ $deleted_patron->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$deleted_patron_id/account/credits/$credit_id") >+ ->status_is(404) >+ ->json_is( '/error_code' => 'not_found' ) >+ ->json_is( '/error' => 'Patron not found' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'list_credits() test' => sub { > plan tests => 3; > >@@ -329,6 +380,56 @@ subtest 'list_credits() test' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'get_debit() tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ } >+ ); >+ my $userid = $patron->userid; >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ >+ my $patron_id = $patron->id; >+ my $debit = $patron->account->add_debit( >+ { >+ amount => 100, >+ description => "A description", >+ type => "NEW_CARD", >+ interface => 'test', >+ } >+ ); >+ my $debit_id = $debit->id; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/debits/$debit_id") >+ ->status_is(200) >+ ->json_is( '/account_line_id' => $debit_id ) >+ ->json_is( '/patron_id' => $patron_id ); >+ >+ $debit->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/debits/$debit_id") >+ ->status_is(404) >+ ->json_is( '/error_code' => 'not_found' ) >+ ->json_is( '/error' => 'Debit not found' ); >+ >+ my $deleted_patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $deleted_patron_id = $deleted_patron->id; >+ $deleted_patron->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$deleted_patron_id/account/debits/$debit_id") >+ ->status_is(404) >+ ->json_is( '/error_code' => 'not_found' ) >+ ->json_is( '/error' => 'Patron not found' ); >+ >+ $schema->storage->txn_rollback; >+}; > > subtest 'list_debits() test' => sub { > plan tests => 3; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38931
:
176840
|
176841
| 176892 |
176893