Bug 29523: Fix tests
Some tests compare things to the output of `->to_api` and are exploding because the (now mandatory) `user` parameter is not passed in the call. In the case of IdP.t I just got rid of the use of `to_api` as we are just trying to acknowledge a new user has been created and the API representation of it is irrelevant. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
42330ef523
commit
9f98be593a
|
|
@ -69,7 +69,10 @@ subtest 'get_user() tests' => sub {
|
|||
my $data = { id_token => $id_token };
|
||||
|
||||
my ( $resolved_patron, $mapped_data, $resolved_domain ) = $client->get_user( { provider => $provider->code, data => $data, interface => 'opac' } );
|
||||
is_deeply( $resolved_patron->to_api, $patron->to_api, 'Patron correctly retrieved' );
|
||||
is_deeply(
|
||||
$resolved_patron->to_api( { user => $patron } ), $patron->to_api( { user => $patron } ),
|
||||
'Patron correctly retrieved'
|
||||
);
|
||||
is( $mapped_data->{firstname}, 'test name', 'Data mapped correctly' );
|
||||
is( $mapped_data->{surname}, undef, 'No surname mapped' );
|
||||
is( $domain->identity_provider_domain_id, $resolved_domain->identity_provider_domain_id, 'Is the same domain' );
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ post '/register_user' => sub {
|
|||
interface => $params->{interface}
|
||||
}
|
||||
);
|
||||
$c->render( status => 200, json => $patron->to_api );
|
||||
$c->render( status => 200, json => $patron->unblessed );
|
||||
} catch {
|
||||
if ( ref($_) eq 'Koha::Exceptions::Auth::Unauthorized' ) {
|
||||
$c->render( status => 401, json => { message => 'unauthorized' } );
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ subtest 'list() tests' => sub {
|
|||
# One erm_user created, should get returned
|
||||
$librarian->discard_changes;
|
||||
$t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200)
|
||||
->json_is( [ $librarian->to_api ] );
|
||||
->json_is( [ $librarian->to_api( { user => $librarian } ) ] );
|
||||
|
||||
my $another_erm_user = $builder->build_object(
|
||||
{
|
||||
|
|
@ -67,7 +67,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
# Two erm_users created, they should both be returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200)
|
||||
->json_is( [ $librarian->to_api ] );
|
||||
->json_is( [ $librarian->to_api( { user => $librarian } ) ] );
|
||||
|
||||
# Warn on unsupported query parameter
|
||||
$t->get_ok("//$userid:$password@/api/v1/erm/users?blah=blah")
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ subtest 'list() tests' => sub {
|
|||
# Three requests exist, expect all three to be returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/ill/requests")
|
||||
->status_is(200)
|
||||
->json_is( [ $req_1->to_api, $req_2->to_api, $ret->to_api ]);
|
||||
->json_is( [ $req_1->to_api({user=> $librarian}), $req_2->to_api({user=> $librarian}), $ret->to_api({user=> $librarian}) ]);
|
||||
|
||||
my $status_query = encode_json({ status => 'REQ' });
|
||||
my $status_alias_query = encode_json({ status_av => $av_code });
|
||||
|
|
@ -177,29 +177,34 @@ subtest 'list() tests' => sub {
|
|||
# x-koha-embed: +strings
|
||||
# Two requests exist with status 'REQ', expect them to be returned
|
||||
# One of which also has a status_alias, expect that to be in that request's body
|
||||
$t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_query" => {"x-koha-embed" => "+strings"} )
|
||||
->status_is(200)
|
||||
->json_is( [
|
||||
{ _strings => { status => $response_status }, %{$req_1->to_api} },
|
||||
{ _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} }
|
||||
]
|
||||
$t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_query" => { "x-koha-embed" => "+strings" } )
|
||||
->status_is(200)->json_is(
|
||||
[
|
||||
{ _strings => { status => $response_status }, %{ $req_1->to_api( { user => $librarian } ) } },
|
||||
{
|
||||
_strings => { status => $response_status, status_av => $response_status_av },
|
||||
%{ $req_2->to_api( { user => $librarian } ) }
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
# One request with status_alias 'print_copy' exists, expect that to be returned
|
||||
$t->get_ok("//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => {"x-koha-embed" => "+strings"} )
|
||||
->status_is(200)
|
||||
->json_is( [
|
||||
{ _strings => { status => $response_status, status_av => $response_status_av }, %{$req_2->to_api} }
|
||||
]
|
||||
$t->get_ok( "//$userid:$password@/api/v1/ill/requests?q=$status_alias_query" => { "x-koha-embed" => "+strings" } )
|
||||
->status_is(200)->json_is(
|
||||
[
|
||||
{
|
||||
_strings => { status => $response_status, status_av => $response_status_av },
|
||||
%{ $req_2->to_api( { user => $librarian } ) }
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
# x-koha-embed: patron
|
||||
my $patron_query = encode_json({ borrowernumber => $patron->borrowernumber });
|
||||
|
||||
# One request related to $patron, make sure it comes back
|
||||
$t->get_ok("//$userid:$password@/api/v1/ill/requests" => {"x-koha-embed" => "patron"} )
|
||||
->status_is(200)
|
||||
->json_has('/0/patron', $patron->to_api);
|
||||
$t->get_ok( "//$userid:$password@/api/v1/ill/requests" => { "x-koha-embed" => "patron" } )->status_is(200)
|
||||
->json_has( '/0/patron', $patron->to_api( { user => $librarian } ) );
|
||||
|
||||
# x-koha-embed: comments
|
||||
# Create comment
|
||||
|
|
@ -226,15 +231,13 @@ subtest 'list() tests' => sub {
|
|||
# ILLHiddenRequestStatuses syspref
|
||||
# Hide 'REQ', expect to return just 1 'RET'
|
||||
t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'REQ' );
|
||||
$t->get_ok( "//$userid:$password@/api/v1/ill/requests" )
|
||||
->status_is(200)
|
||||
->json_is( [ $ret->to_api ] );
|
||||
$t->get_ok("//$userid:$password@/api/v1/ill/requests")->status_is(200)
|
||||
->json_is( [ $ret->to_api( { user => $librarian } ) ] );
|
||||
|
||||
# Hide 'RET', expect to return 2 'REQ'
|
||||
t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'RET' );
|
||||
$t->get_ok( "//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes" )
|
||||
->status_is(200)
|
||||
->json_is( [ $req_1->to_api, $req_2->to_api ]);
|
||||
$t->get_ok("//$userid:$password@/api/v1/ill/requests?_order_by=staff_notes")->status_is(200)
|
||||
->json_is( [ $req_1->to_api( { user => $librarian } ), $req_2->to_api( { user => $librarian } ) ] );
|
||||
|
||||
# Status code
|
||||
# Warn on unsupported query parameter
|
||||
|
|
|
|||
Loading…
Reference in New Issue