Bugzilla – Attachment 84474 Details for
Bug 22206
Add routes to enable suspension or resumption of holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22206: Unit tests
Bug-22206-Unit-tests.patch (text/plain), 3.46 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-01-28 10:44:28 UTC
(
hide
)
Description:
Bug 22206: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-01-28 10:44:28 UTC
Size:
3.46 KB
patch
obsolete
>From d7f258c448288bd380a2137d4361bfb9ed9cfd1b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 28 Jan 2019 07:39:47 -0300 >Subject: [PATCH] Bug 22206: Unit tests > >--- > t/db_dependent/api/v1/holds.t | 78 ++++++++++++++++++++++++++++++++++- > 1 file changed, 77 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index fd8987ade7..700af99d7a 100644 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::Mojo; > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -328,6 +328,82 @@ subtest 'Reserves with itemtype' => sub { > > $schema->storage->txn_rollback; > >+subtest 'suspend and resume tests' => sub { >+ >+ plan tests => 20; >+ >+ $schema->storage->txn_begin; >+ >+ my $password = 'AbcdEFG123'; >+ >+ my $patron = $builder->build_object( >+ { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 1 } } ); >+ $patron->set_password($password); >+ my $userid = $patron->userid; >+ >+ # Disable logging >+ t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); >+ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+ my $hold = $builder->build_object( >+ { class => 'Koha::Holds', >+ value => { suspend => 0, suspend_until => undef, waitingdate => undef } >+ } >+ ); >+ >+ ok( !$hold->is_suspended, 'Hold is not suspended' ); >+ $t->post_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) >+ ->status_is( 201, 'Hold suspension created' ); >+ >+ $hold->discard_changes; # refresh object >+ >+ ok( $hold->is_suspended, 'Hold is suspended' ); >+ $t->json_is( >+ '/expiration_date', >+ output_pref( >+ { dt => dt_from_string( $hold->suspend_until ), >+ dateformat => 'rfc3339', >+ dateonly => 1 >+ } >+ ) >+ ); >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) >+ ->status_is( 204, "Correct status when deleting a resource" ) >+ ->json_is( undef ); >+ >+ # Pass a an expiration date for the suspension >+ my $date = dt_from_string()->add( days => 5 ); >+ $t->post_ok( >+ "//$userid:$password@/api/v1/holds/" >+ . $hold->id >+ . "/suspension" => json => { >+ expiration_date => >+ output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } ) >+ } >+ )->status_is( 201, 'Hold suspension created' ) >+ ->json_is( '/expiration_date', >+ output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } ) ); >+ >+ $t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) >+ ->status_is( 204, "Correct status when deleting a resource" ) >+ ->json_is( undef ); >+ >+ $hold->set_waiting->discard_changes; >+ >+ $t->post_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) >+ ->status_is( 400, 'Cannot suspend waiting hold' ) >+ ->json_is( '/error', 'Found hold cannot be suspended. Status=W' ); >+ >+ $hold->set_waiting(1)->discard_changes; >+ >+ $t->post_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) >+ ->status_is( 400, 'Cannot suspend waiting hold' ) >+ ->json_is( '/error', 'Found hold cannot be suspended. Status=T' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > sub create_biblio { > my ($title) = @_; > >-- >2.20.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 22206
:
84473
|
84474
|
84475
|
85056
|
85057
|
85058
|
85468
|
85469
|
85470
|
85471
|
85862
|
85864
|
85865
|
85866
|
85867
|
85868