Bugzilla – Attachment 168258 Details for
Bug 34920
ERM breaks if an ERM authorized value is missing a description
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34920: Add API endpoint tests
Bug-34920-Add-API-endpoint-tests.patch (text/plain), 3.45 KB, created by
Martin Renvoize (ashimema)
on 2024-06-28 15:11:02 UTC
(
hide
)
Description:
Bug 34920: Add API endpoint tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-06-28 15:11:02 UTC
Size:
3.45 KB
patch
obsolete
>From 394263fe9430f904443776b4f0a521e0e95cda86 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 29 Feb 2024 13:44:12 +0000 >Subject: [PATCH] Bug 34920: Add API endpoint tests > >prove koha/t/db_dependent/api/v1/authorised_values.t > >Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/api/v1/authorised_values.t | 36 ++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/authorised_values.t b/t/db_dependent/api/v1/authorised_values.t >index 187087d4408..067701e1be4 100755 >--- a/t/db_dependent/api/v1/authorised_values.t >+++ b/t/db_dependent/api/v1/authorised_values.t >@@ -26,6 +26,8 @@ use t::lib::Mocks; > use Koha::AuthorisedValues; > use Koha::Database; > >+use JSON qw( encode_json ); >+ > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >@@ -34,7 +36,7 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > > subtest 'list_av_from_category() tests' => sub { > >- plan tests => 11; >+ plan tests => 22; > > $schema->storage->txn_begin; > >@@ -83,5 +85,37 @@ subtest 'list_av_from_category() tests' => sub { > $t->get_ok("//$unauth_userid:$password@/api/v1/authorised_value_categories/$av_cat/authorised_values") > ->status_is(403); > >+ # Test the query webservice endpoint for multiple av_cats >+ my $av_cat_2 = >+ $builder->build_object( { class => 'Koha::AuthorisedValueCategories', value => { category_name => 'cat_a' } } ); >+ my $av_cat_3 = >+ $builder->build_object( { class => 'Koha::AuthorisedValueCategories', value => { category_name => 'cat_b' } } ); >+ my $query = { "me.category_name" => [ $av_cat_2->category_name, $av_cat_3->category_name ] }; >+ $t->get_ok( "//$userid:$password@/api/v1/authorised_value_categories?q=" . encode_json($query) )->status_is(200) >+ ->json_is( [ $av_cat_2->to_api, $av_cat_3->to_api ] ); >+ >+ # Test the above but with x-koha-embed: authorised_values >+ my $embedded_query = { "me.category_name" => [ $av_cat_2->category_name, $av_cat_3->category_name ] }; >+ $t->get_ok( "//$userid:$password@/api/v1/authorised_value_categories?q=" >+ . encode_json($embedded_query) => { 'x-koha-embed' => 'authorised_values' } )->status_is(200) >+ ->json_has( '/0/authorised_values', 'authorised_values object correctly embedded' ) >+ ->json_has( '/1/authorised_values', 'authorised_values object correctly embedded' ) >+ ->json_hasnt( '/2/', 'authorised_values object correctly embedded' ); >+ >+ # Test the query webservice endpoint for multiple av_cats with authorised_values embedded >+ my $av_2 = $builder->build_object( >+ { class => 'Koha::AuthorisedValues', value => { category => $av_cat_2->category_name, lib => undef } } ); >+ my $av_3 = $builder->build_object( >+ { >+ class => 'Koha::AuthorisedValues', >+ value => { category => $av_cat_2->category_name, lib => 'description_value' } >+ } >+ ); >+ >+ my $embedded_av_query = { "me.category_name" => [ $av_cat_2->category_name ] }; >+ $t->get_ok( "//$userid:$password@/api/v1/authorised_value_categories?q=" >+ . encode_json($embedded_av_query) => { 'x-koha-embed' => 'authorised_values' } )->status_is(200) >+ ->json_is( [ { %{ $av_cat_2->to_api }, authorised_values => [ $av_2->to_api, $av_3->to_api ] } ] ); >+ > $schema->storage->txn_rollback; > }; >-- >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 34920
:
162036
|
162037
|
162120
|
162121
|
162600
|
162601
|
162604
|
162605
|
162608
|
162609
|
163628
|
163629
|
163630
|
163631
|
168257
| 168258 |
168259
|
168260