Bugzilla – Attachment 126980 Details for
Bug 29290
Add routes to fetch checkouts for a given biblio
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29290: Unit tests
Bug-29290-Unit-tests.patch (text/plain), 3.40 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-10-27 12:08:08 UTC
(
hide
)
Description:
Bug 29290: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-10-27 12:08:08 UTC
Size:
3.40 KB
patch
obsolete
>From 01cec769183b3277acf5734ae1f451c426b1ac86 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 27 Oct 2021 09:06:44 -0300 >Subject: [PATCH] Bug 29290: Unit tests > >This patch adds unit tests for the new route. All behaviors are tested: > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/biblios.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/biblios.t | 67 ++++++++++++++++++++++++++++++++- > 1 file changed, 66 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index 25665ed5cf..821c806a4d 100755 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -20,7 +20,7 @@ use Modern::Perl; > use utf8; > use Encode; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::MockModule; > use Test::Mojo; > use Test::Warn; >@@ -29,8 +29,12 @@ use t::lib::Mocks; > use t::lib::TestBuilder; > > use C4::Auth; >+use C4::Circulation qw( AddIssue AddReturn ); >+ > use Koha::Biblios; > use Koha::Database; >+use Koha::Checkouts; >+use Koha::Old::Checkouts; > > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; >@@ -494,3 +498,64 @@ subtest 'pickup_locations() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'get_checkouts() tests' => sub { >+ >+ plan tests => 14; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 } >+ } >+ ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ $patron->discard_changes; >+ my $userid = $patron->userid; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ $t->get_ok("//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") >+ ->status_is(403); >+ >+ $patron->flags(1)->store; # circulate permissions >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") >+ ->status_is(200) >+ ->json_is( '' => [], 'No checkouts on the biblio' ); >+ >+ my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); >+ my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); >+ >+ AddIssue( $patron->unblessed, $item_1->barcode ); >+ AddIssue( $patron->unblessed, $item_2->barcode ); >+ >+ my $ret = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") >+ ->status_is(200) >+ ->tx->res->json; >+ >+ my $checkout_1 = Koha::Checkouts->find({ itemnumber => $item_1->id }); >+ my $checkout_2 = Koha::Checkouts->find({ itemnumber => $item_2->id }); >+ >+ is_deeply( $ret, [ $checkout_1->to_api, $checkout_2->to_api ] ); >+ >+ AddReturn( $item_1->barcode ); >+ >+ $ret = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts") >+ ->status_is(200) >+ ->tx->res->json; >+ >+ is_deeply( $ret, [ $checkout_2->to_api ] ); >+ >+ $ret = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/checkouts?checked_in=1") >+ ->status_is(200) >+ ->tx->res->json; >+ >+ my $old_checkout_1 = Koha::Old::Checkouts->find( $checkout_1->id ); >+ >+ is_deeply( $ret, [ $old_checkout_1->to_api ] ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.32.0
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 29290
:
126617
|
126618
|
126622
|
126625
|
126637
|
126638
|
126639
|
126957
|
126958
|
126959
|
126980
|
126982