Bugzilla – Attachment 168369 Details for
Bug 36641
Add an endpoint to list circulation rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36641: Make tests cover all code paths
Bug-36641-Make-tests-cover-all-code-paths.patch (text/plain), 5.19 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-07-02 13:17:54 UTC
(
hide
)
Description:
Bug 36641: Make tests cover all code paths
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-07-02 13:17:54 UTC
Size:
5.19 KB
patch
obsolete
>From 9096122e2464ddbcb4fa083298296cdb535a9246 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 2 Jul 2024 10:12:35 -0300 >Subject: [PATCH] Bug 36641: Make tests cover all code paths > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/CirculationRules.pm | 6 +-- > t/db_dependent/api/v1/circulation_rules.t | 54 +++++++++++++++++++++-- > 2 files changed, 53 insertions(+), 7 deletions(-) > >diff --git a/Koha/REST/V1/CirculationRules.pm b/Koha/REST/V1/CirculationRules.pm >index 0a112ff03c3..45d3038ca3a 100644 >--- a/Koha/REST/V1/CirculationRules.pm >+++ b/Koha/REST/V1/CirculationRules.pm >@@ -58,7 +58,7 @@ sub list_effective_rules { > my $type = Koha::ItemTypes->find($item_type); > return $c->render_invalid_parameter_value( > { >- path => '/query/item_type', >+ path => '/query/item_type_id', > values => { > uri => '/api/v1/item_types', > field => 'item_type_id' >@@ -71,7 +71,7 @@ sub list_effective_rules { > my $library = Koha::Libraries->find($branchcode); > return $c->render_invalid_parameter_value( > { >- path => '/query/library', >+ path => '/query/library_id', > values => { > uri => '/api/v1/libraries', > field => 'library_id' >@@ -84,7 +84,7 @@ sub list_effective_rules { > my $category = Koha::Patron::Categories->find($patron_category); > return $c->render_invalid_parameter_value( > { >- path => '/query/patron_category', >+ path => '/query/patron_category_id', > values => { > uri => '/api/v1/patron_categories', > field => 'patron_category_id' >diff --git a/t/db_dependent/api/v1/circulation_rules.t b/t/db_dependent/api/v1/circulation_rules.t >index 1c5e0a04ac3..a24cd689494 100755 >--- a/t/db_dependent/api/v1/circulation_rules.t >+++ b/t/db_dependent/api/v1/circulation_rules.t >@@ -34,7 +34,7 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > > subtest 'list_effective_rules() tests' => sub { > >- plan tests => 26; >+ plan tests => 32; > > $schema->storage->txn_begin; > >@@ -140,19 +140,65 @@ subtest 'list_effective_rules() tests' => sub { > $t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules_blah=blah")->status_is(400) > ->json_is( [ { path => '/query/rules_blah', message => 'Malformed query string' } ] ); > >+ # Make sure we have a non-existent library >+ my $library_to_delete = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $non_existent_library = $library_to_delete->branchcode; >+ $library_to_delete->delete; >+ > # Warn on incorrect query parameter value >- $t->get_ok("//$userid:$password@/api/v1/circulation_rules?library_id=SMITH")->status_is(400)->json_is( >+ $t->get_ok("//$userid:$password@/api/v1/circulation_rules?library_id=$non_existent_library")->status_is(400) >+ ->json_is( > '' => { > error => 'Invalid parameter value', > error_code => 'invalid_parameter_value', >- path => '/query/library', >+ path => '/query/library_id', > values => { > uri => '/api/v1/libraries', > field => 'library_id' > } > }, > "Invalid parameter value handled correctly" >- ); >+ ); >+ >+ # Make sure we have a non-existent category >+ my $category_to_delete = $builder->build_object( { class => 'Koha::Patron::Categories' } ); >+ my $non_existent_category = $category_to_delete->categorycode; >+ $category_to_delete->delete; >+ >+ # Warn on incorrect query parameter value >+ $t->get_ok("//$userid:$password@/api/v1/circulation_rules?patron_category_id=$non_existent_category") >+ ->status_is(400)->json_is( >+ '' => { >+ error => 'Invalid parameter value', >+ error_code => 'invalid_parameter_value', >+ path => '/query/patron_category_id', >+ values => { >+ uri => '/api/v1/patron_categories', >+ field => 'patron_category_id' >+ } >+ }, >+ "Invalid parameter value handled correctly" >+ ); >+ >+ # Make sure we have a non-existent itemtype >+ my $itemtype_to_delete = $builder->build_object( { class => 'Koha::ItemTypes' } ); >+ my $non_existent_itemtype = $itemtype_to_delete->itemtype; >+ $itemtype_to_delete->delete; >+ >+ # Warn on incorrect query parameter value >+ $t->get_ok("//$userid:$password@/api/v1/circulation_rules?item_type_id=$non_existent_itemtype")->status_is(400) >+ ->json_is( >+ '' => { >+ error => 'Invalid parameter value', >+ error_code => 'invalid_parameter_value', >+ path => '/query/item_type_id', >+ values => { >+ uri => '/api/v1/item_types', >+ field => 'item_type_id' >+ } >+ }, >+ "Invalid parameter value handled correctly" >+ ); > > # Unauthorized access > $t->get_ok("//$unauth_userid:$password@/api/v1/circulation_rules")->status_is(403); >-- >2.45.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 36641
:
165086
|
167937
|
167938
|
167946
|
167947
|
168018
|
168019
|
168020
|
168023
|
168024
|
168025
|
168365
|
168366
|
168367
|
168368
|
168369
|
168370
|
168378
|
168379
|
168395
|
168396
|
168397
|
168398
|
168399
|
168400
|
168401
|
168841
|
168874
|
168875
|
168876
|
168877
|
168878
|
168879
|
168880
|
168881
|
168882
|
168883
|
168884
|
168905
|
168906
|
168907
|
168908
|
168909
|
168910
|
168911
|
168912
|
168913
|
168914
|
168915
|
168916
|
168926
|
168927
|
168928
|
168929
|
168930
|
168931
|
168932
|
168933
|
168934
|
168935
|
168936
|
168937
|
168938
|
168940
|
169013
|
169014
|
169015
|
169016
|
169017
|
169018
|
169019
|
169020
|
169021
|
169022
|
169023
|
169024
|
169025
|
169026