Bugzilla – Attachment 178001 Details for
Bug 35246
Bad data erorrs should provide better logs for api/v1/biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35246: Unit tests
Bug-35246-Unit-tests.patch (text/plain), 2.64 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-02-13 13:03:46 UTC
(
hide
)
Description:
Bug 35246: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-02-13 13:03:46 UTC
Size:
2.64 KB
patch
obsolete
>From 0e4b6dcac379a22731ba0ebe08f9c7f020533a62 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 13 Feb 2025 09:58:57 -0300 >Subject: [PATCH] Bug 35246: Unit tests > >--- > t/db_dependent/Koha/Biblio.t | 9 ++++++++- > t/db_dependent/api/v1/biblios.t | 9 ++++++++- > 2 files changed, 16 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index 9d697b7850e..c1fd10a01e3 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -587,7 +587,7 @@ subtest 'to_api() tests' => sub { > my $biblioitem_api = $biblio->biblioitem->to_api; > my $biblio_api = $biblio->to_api; > >- plan tests => ( scalar keys %{$biblioitem_api} ) + 1; >+ plan tests => ( scalar keys %{$biblioitem_api} ) + 4; > > foreach my $key ( keys %{$biblioitem_api} ) { > is( $biblio_api->{$key}, $biblioitem_api->{$key}, "$key is added to the biblio object" ); >@@ -596,6 +596,13 @@ subtest 'to_api() tests' => sub { > $biblio_api = $biblio->to_api( { embed => { items => {} } } ); > is_deeply( $biblio_api->{items}, [ $item->to_api ], 'Item correctly embedded' ); > >+ $biblio->biblioitem->delete(); >+ throws_ok { $biblio->to_api } >+ 'Koha::Exceptions::RelatedObjectNotFound', >+ 'Exception thrown if the biblioitem accessor returns undef'; >+ is( $@->class, 'Koha::Biblioitem' ); >+ is( $@->accessor, 'biblioitem' ); >+ > $schema->storage->txn_rollback; > }; > >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index f47c5f8bd2f..d0e809dfec5 100755 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -50,7 +50,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); > > subtest 'get() tests' => sub { > >- plan tests => 22; >+ plan tests => 26; > > $schema->storage->txn_begin; > >@@ -97,6 +97,13 @@ subtest 'get() tests' => sub { > $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } ) > ->status_is(200)->content_is( $biblio->metadata->record->as_formatted ); > >+ # Simulate a data error situation (BZ35246) >+ $biblio->biblioitem->delete(); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'application/json' } ) >+ ->status_is(500)->json_is( '/error_code', 'internal_server_error' ) >+ ->json_is( '/error', 'Something went wrong, check Koha logs for details.' ); >+ > $biblio->delete; > $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'application/marc' } ) > ->status_is(404)->json_is( '/error', 'Bibliographic record not found' ); >-- >2.48.1
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 35246
:
178001
|
178002
|
178007
|
178018
|
178019
|
178173