Bugzilla – Attachment 93753 Details for
Bug 23677
Add API route to get a bibliographic record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23677: Unit tests
Bug-23677-Unit-tests.patch (text/plain), 3.33 KB, created by
Kyle M Hall (khall)
on 2019-10-04 16:14:02 UTC
(
hide
)
Description:
Bug 23677: Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2019-10-04 16:14:02 UTC
Size:
3.33 KB
patch
obsolete
>From f06562588e763a62685bc18080745ac1ddbfc90f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 26 Sep 2019 16:23:49 -0300 >Subject: [PATCH] Bug 23677: Unit tests > >This patch introduces tests for the GET /biblios/{biblio_id} endpoint. >It tries to cover all the use cases. > >To test: >- Apply this patchset >- Run: > $ kshell > k$ prove t/db_dependent/api/v1/biblios.t >=> SUCCESS: Tests pass! >- Use Postman (or your favourite tool) to test the API >=> SUCCESS: Works as expected! >- Sign off :-D > >Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/api/v1/biblios.t | 63 ++++++++++++++++++++++++++++++++- > 1 file changed, 62 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index 6a503b5188..8bf7e4d97e 100644 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Mojo; > use Test::Warn; > >@@ -35,6 +35,67 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > > my $t = Test::Mojo->new('Koha::REST::V1'); > >+subtest 'get() tests' => sub { >+ >+ plan tests => 18; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 } >+ } >+ ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ $patron->discard_changes; >+ my $userid = $patron->userid; >+ >+ my $biblio = $builder->build_sample_biblio({ >+ title => 'The unbearable lightness of being', >+ author => 'Milan Kundera' >+ }); >+ $t->get_ok("//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber) >+ ->status_is(403); >+ >+ $patron->flags(4)->store; >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber >+ => { Accept => 'application/weird+format' } ) >+ ->status_is(406) >+ ->json_is( [ "application/json", >+ "application/marcxml+xml", >+ "application/marc-in-json", >+ "application/marc" ] ); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber >+ => { Accept => 'application/json' } ) >+ ->status_is(200) >+ ->json_is( '/title', 'The unbearable lightness of being' ) >+ ->json_is( '/author', 'Milan Kundera' ); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber >+ => { Accept => 'application/marcxml+xml' } ) >+ ->status_is(200); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber >+ => { Accept => 'application/marc-in-json' } ) >+ ->status_is(200); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber >+ => { Accept => 'application/marc' } ) >+ ->status_is(200); >+ >+ $biblio->delete; >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber >+ => { Accept => 'application/marc' } ) >+ ->status_is(404) >+ ->json_is( '/error', 'Object not found.' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'delete() tests' => sub { > > plan tests => 7; >-- >2.21.0 (Apple Git-122)
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 23677
:
93172
|
93173
|
93174
|
93175
|
93622
|
93623
|
93679
|
93680
|
93681
|
93682
|
93750
|
93751
|
93752
| 93753