Bugzilla – Attachment 64842 Details for
Bug 17371
Add routes for biblios [OMNIBUS]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17371 - REST API: add CRUD for biblios (QA followup)
Bug-17371---REST-API-add-CRUD-for-biblios.patch (text/plain), 5.47 KB, created by
Jiri Kozlovsky
on 2017-07-06 09:56:38 UTC
(
hide
)
Description:
Bug 17371 - REST API: add CRUD for biblios (QA followup)
Filename:
MIME Type:
Creator:
Jiri Kozlovsky
Created:
2017-07-06 09:56:38 UTC
Size:
5.47 KB
patch
obsolete
>From 9954e8b721ae4107fac97017471d25cad62690fd Mon Sep 17 00:00:00 2001 >From: Jiri Kozlovsky <mail@jkozlovsky.cz> >Date: Tue, 27 Jun 2017 18:27:48 +0000 >Subject: [PATCH] Bug 17371 - REST API: add CRUD for biblios > >QA followup > >Note: Rebased on master >--- > api/v1/swagger/definitions/biblio.json | 4 +- > t/db_dependent/api/v1/biblios.t | 85 ++++++++++++++++------------- > t/db_dependent/api/v1/swagger/definitions.t | 7 ++- > 3 files changed, 55 insertions(+), 41 deletions(-) > >diff --git a/api/v1/swagger/definitions/biblio.json b/api/v1/swagger/definitions/biblio.json >index a46a55d..ecd4aab 100644 >--- a/api/v1/swagger/definitions/biblio.json >+++ b/api/v1/swagger/definitions/biblio.json >@@ -33,11 +33,11 @@ > "description": "publication or copyright date from the MARC record" > }, > "timestamp": { >- "type": "string", >+ "type": ["string", "null"], > "description": "date and time this record was last touched" > }, > "datecreated": { >- "type": "string", >+ "type": ["string", "null"], > "description": "the date this record was added to Koha" > }, > "abstract": { >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index 5f54a18..3aab9dc 100644 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -17,41 +17,47 @@ > > use Modern::Perl; > >-use t::lib::TestBuilder; >- > use Test::More tests => 3; > use Test::Mojo; >+use Test::Warn; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ > use Data::Dumper; > use C4::Auth; > use C4::Context; >+ > use Koha::Database; >-use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'UNIMARC' ); >+use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'MARC21' ); >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+t::lib::Mocks::mock_preference( 'SessionStorage', 'tmp' ); >+ >+my $remote_address = '127.0.0.1'; >+my $t = Test::Mojo->new('Koha::REST::V1'); > > BEGIN { > use_ok('Koha::Biblios'); > } > >-my $schema = Koha::Database->schema; > my $dbh = C4::Context->dbh; >-my $builder = t::lib::TestBuilder->new; >- >-$ENV{REMOTE_ADDR} = '127.0.0.1'; >-my $t = Test::Mojo->new('Koha::REST::V1'); >- >-$schema->storage->txn_begin; > > my $file = MARC::File::XML->in( 't/db_dependent/Record/testrecords/marcxml_utf8.xml' ); > my $record = $file->next(); >-my ( $biblionumber, $itemnumber ); >+ >+$schema->storage->txn_begin; > > my $librarian = $builder->build({ >- source => "Borrower", >- value => { >- categorycode => 'S', >- branchcode => 'NPL', >- flags => 1, # editcatalogue >- }, >-}); >+ source => "Borrower", >+ value => { >+ categorycode => 'S', >+ branchcode => 'NPL', >+ flags => 1, # editcatalogue >+ }, >+ }); > > my $session = C4::Auth::get_session(''); > $session->param('number', $librarian->{ borrowernumber }); >@@ -60,31 +66,34 @@ $session->param('ip', '127.0.0.1'); > $session->param('lasttime', time()); > $session->flush; > >+my ( $biblionumber, $itemnumber ); >+ > subtest 'Create biblio' => sub { >- plan tests => 5; >- >- my $tx = $t->ua->build_tx(POST => '/api/v1/biblios' => $record->as_xml()); >- $tx->req->env({REMOTE_ADDR => '127.0.0.1'}); >- $tx->req->cookies({name => 'CGISESSID', value => $session->id}); >- $t->request_ok($tx) >- ->status_is(201); >- $biblionumber = $tx->res->json->{biblionumber}; >- $itemnumber = $tx->res->json->{items}; >- >- $t->json_is('/biblionumber' => $biblionumber) >- ->json_is('/items' => $itemnumber) >- ->header_like(Location => qr/$biblionumber/, 'Location header contains biblionumber'); >+ plan tests => 5; >+ >+ my $tx = $t->ua->build_tx(POST => '/api/v1/biblios' => $record->as_xml()); >+ $tx->req->env({REMOTE_ADDR => '127.0.0.1'}); >+ $tx->req->cookies({name => 'CGISESSID', value => $session->id}); >+ $t->request_ok($tx) >+ ->status_is(201); >+ $biblionumber = $tx->res->json->{biblionumber}; >+ $itemnumber = $tx->res->json->{items}; >+ >+ $t->json_is('/biblionumber' => $biblionumber) >+ ->json_is('/items' => $itemnumber) >+ ->header_like(Location => qr/$biblionumber/, 'Location header contains biblionumber'); >+ > }; > > subtest 'Delete biblio' => sub { >- plan tests => 2; >+ plan tests => 2; > >- my $tx = $t->ua->build_tx(DELETE => "/api/v1/biblios/$biblionumber"); >- $tx->req->env({REMOTE_ADDR => '127.0.0.1'}); >- $tx->req->cookies({name => 'CGISESSID', value => $session->id}); >- $t->request_ok($tx) >- ->status_is(200); >-}; >+ my $tx = $t->ua->build_tx(DELETE => "/api/v1/biblios/$biblionumber"); >+ $tx->req->env({REMOTE_ADDR => '127.0.0.1'}); >+ $tx->req->cookies({name => 'CGISESSID', value => $session->id}); >+ $t->request_ok($tx) >+ ->status_is(200); > >+}; > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/api/v1/swagger/definitions.t b/t/db_dependent/api/v1/swagger/definitions.t >index b1fb184..a5ca342 100644 >--- a/t/db_dependent/api/v1/swagger/definitions.t >+++ b/t/db_dependent/api/v1/swagger/definitions.t >@@ -46,7 +46,12 @@ my $schema = Koha::Database->new->schema; > my @definition_names = keys %{ $api_spec->{definitions} }; > > subtest 'api/v1/definitions/*.json up-to-date with corresponding Koha-object' => sub { >- plan tests => 2*(scalar(@definition_names) - 1); >+ >+ # we have to subtract definitions which are not Koha-object (only one subtest for those): >+ # error >+ # holds >+ # biblios >+ plan tests => 2*(scalar(@definition_names)) - 3; > > foreach my $name (@definition_names) { > my $definition = $api_spec->{definitions}->{$name}; >-- >2.1.4
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 17371
:
55898
|
58995
|
58996
|
64842