Bugzilla – Attachment 132138 Details for
Bug 30165
Several q parameters break the filters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[OPTION 1] Bug 30165: (follow-up) Address OpenAPI vs. no-OpenAPI in the tests
OPTION-1-Bug-30165-follow-up-Address-OpenAPI-vs-no.patch (text/plain), 4.74 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-03-24 12:46:26 UTC
(
hide
)
Description:
[OPTION 1] Bug 30165: (follow-up) Address OpenAPI vs. no-OpenAPI in the tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-03-24 12:46:26 UTC
Size:
4.74 KB
patch
obsolete
>From fe167c7177c2a03e77b0a71360d15ca2d491b663 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 24 Mar 2022 09:40:48 -0300 >Subject: [PATCH] [OPTION 1] Bug 30165: (follow-up) Address OpenAPI vs. > no-OpenAPI in the tests > >Our objects.search helper is written for being used in our API >controllers, which get their query parameters processed by the OpenAPI >plugin, using JSON::Validator. > >Particularly, the 'q' parameter is defined as 'multi' on our spec, which >means objects.search always gets it as an arrayref. > >As the Objects.t tests are not using the OpenAPI plugin, a hashref is >generated as only one q= is being passed. This patch adds an extra >(empty) q param to the tests to overcome this. > >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t >=> FAIL: Tests fail! >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests pass! >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index 8deee9da7d..1e2d1dce2d 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -326,7 +326,7 @@ subtest 'objects.search helper, encoding' => sub { > $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => 'â¤Argentinaâ¤' } }); > > my $t = Test::Mojo->new; >- $t->get_ok('/cities?q={"country": "â¤Argentinaâ¤"}') >+ $t->get_ok('/cities?q={"country": "â¤Argentinaâ¤"}&q=[]') > ->status_is(200) > ->json_has('/0') > ->json_hasnt('/1') >@@ -424,10 +424,10 @@ subtest 'object.search helper with q parameter' => sub { > my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); > > my $t = Test::Mojo->new; >- $t->get_ok('/biblios?q={"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}') >+ $t->get_ok('/biblios?q={"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}&q=[]') > ->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); > >- $t->get_ok('/biblios?q={"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}') >+ $t->get_ok('/biblios?q={"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}&q=[]') > ->json_is('/count' => 2, 'there should be 2 biblios with suggestions of patron 2'); > > $schema->storage->txn_rollback; >@@ -472,13 +472,13 @@ subtest 'object.search helper with all query methods' => sub { > my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); > > my $t = Test::Mojo->new; >- $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron1->cardnumber}) >+ $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}&q=[]' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron1->cardnumber}) > ->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); > >- $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron2->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron2->cardnumber}) >+ $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron2->firstname.'"}&q=[]' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron2->cardnumber}) > ->json_is('/count' => 2, 'there should be 2 biblios with suggestions of patron 2'); > >- $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron2->cardnumber}) >+ $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}&q=[]' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron2->cardnumber}) > ->json_is('/count' => 0, 'there shouldn\'t be biblios where suggester has patron1 fistname and patron2 id'); > > $schema->storage->txn_rollback; >-- >2.32.0
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 30165
:
131111
|
131706
|
131707
|
131759
|
131760
|
131761
|
131803
|
131804
|
131805
|
131821
|
131822
|
131823
|
132138
|
132139