Bugzilla – Attachment 137574 Details for
Bug 31128
Add effective_not_for_loan_status to API item objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31128: Unit tests
Bug-31128-Unit-tests.patch (text/plain), 3.63 KB, created by
Nick Clemens (kidclamp)
on 2022-07-11 16:37:09 UTC
(
hide
)
Description:
Bug 31128: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-07-11 16:37:09 UTC
Size:
3.63 KB
patch
obsolete
>From fe5c0a9c01e4b0e40963bc1c666adaa2bb73b19c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 11 Jul 2022 13:46:05 +0100 >Subject: [PATCH] Bug 31128: Unit tests > >This patch adds unit tests for the new effective_not_for_loan_status >which I add to the items api responses in this patchset. > >Test plan >1) Run the unit test without applying the next commit, it should fail >2) RUn the test again after applying the next commit, it should pass >--- > t/db_dependent/api/v1/items.t | 37 +++++++++++++++++++++++++++++------ > 1 file changed, 31 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/api/v1/items.t b/t/db_dependent/api/v1/items.t >index 41f574ccf7..5dd047937d 100755 >--- a/t/db_dependent/api/v1/items.t >+++ b/t/db_dependent/api/v1/items.t >@@ -101,7 +101,7 @@ subtest 'list() tests' => sub { > > subtest 'get() tests' => sub { > >- plan tests => 17; >+ plan tests => 30; > > $schema->storage->txn_begin; > >@@ -143,21 +143,46 @@ subtest 'get() tests' => sub { > > my $biblio = $builder->build_sample_biblio; > my $itype = >- $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype; >+ $builder->build_object( { class => 'Koha::ItemTypes' } ); > $item = $builder->build_sample_item( >- { biblionumber => $biblio->biblionumber, itype => $itype } ); >+ { biblionumber => $biblio->biblionumber, itype => $itype->itemtype } ); >+ >+ isnt( $biblio->itemtype, $itype->itemtype, "Test biblio level itemtype and item level itemtype do not match"); > > $t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) > ->status_is( 200, 'SWAGGER3.2.2' ) >- ->json_is( '/item_type_id' => $itype, 'item-level_itypes:0' ) >+ ->json_is( '/item_type_id' => $itype->itemtype, 'item-level_itypes:0' ) > ->json_is( '/effective_item_type_id' => $biblio->itemtype, 'item-level_itypes:0' ); > > t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); > > $t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) > ->status_is( 200, 'SWAGGER3.2.2' ) >- ->json_is( '/item_type_id' => $itype, 'item-level_itype:1' ) >- ->json_is( '/effective_item_type_id' => $itype, 'item-level_itypes:1' ); >+ ->json_is( '/item_type_id' => $itype->itemtype, 'item-level_itype:1' ) >+ ->json_is( '/effective_item_type_id' => $itype->itemtype, 'item-level_itypes:1' ); >+ >+ >+ my $biblio_itype = Koha::ItemTypes->find($biblio->itemtype); >+ $biblio_itype->notforloan(3)->store(); >+ $itype->notforloan(2)->store(); >+ $item->notforloan(1)->store(); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) >+ ->status_is( 200, 'SWAGGER3.2.2' ) >+ ->json_is( '/not_for_loan_status' => 1, 'not_for_loan_status is 1' ) >+ ->json_is( '/effective_not_for_loan_status' => 1, 'effective_not_for_loan_status picks up item level' ); >+ >+ $item->notforloan(0)->store(); >+ $t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) >+ ->status_is( 200, 'SWAGGER3.2.2' ) >+ ->json_is( '/not_for_loan_status' => 0, 'not_for_loan_status is 0' ) >+ ->json_is( '/effective_not_for_loan_status' => 2, 'effective_not_for_loan_status now picks up itemtype level - item-level_itypes:1' ); >+ >+ t::lib::Mocks::mock_preference( 'item-level_itypes', 0 ); >+ $t->get_ok( "//$userid:$password@/api/v1/items/" . $item->itemnumber ) >+ ->status_is( 200, 'SWAGGER3.2.2' ) >+ ->json_is( '/not_for_loan_status' => 0, 'not_for_loan_status is 0' ) >+ ->json_is( '/effective_not_for_loan_status' => 3, 'effective_not_for_loan_status now picks up itemtype level - item-level_itypes:0' ); > > $schema->storage->txn_rollback; > }; >-- >2.30.2
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 31128
:
137507
|
137508
|
137574
|
137575
|
137576
|
137577
|
137593
|
137594
|
138023
|
138024