Bugzilla – Attachment 162605 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.31 KB, created by
Pedro Amorim
on 2024-02-29 15:47:56 UTC
(
hide
)
Description:
Bug 34920: Add API endpoint tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-02-29 15:47:56 UTC
Size:
3.31 KB
patch
obsolete
>From b626ada3362746613513e4805f203466fa23d878 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 >--- > 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.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 34920
:
162036
|
162037
|
162120
|
162121
|
162600
|
162601
|
162604
|
162605
|
162608
|
162609
|
163628
|
163629
|
163630
|
163631
|
168257
|
168258
|
168259
|
168260