Bugzilla – Attachment 114612 Details for
Bug 20212
Improve performance of acquisitions receive page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20212: Controller changes regression tests
Bug-20212-Controller-changes-regression-tests.patch (text/plain), 4.24 KB, created by
Martin Renvoize (ashimema)
on 2020-12-22 16:09:02 UTC
(
hide
)
Description:
Bug 20212: Controller changes regression tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-12-22 16:09:02 UTC
Size:
4.24 KB
patch
obsolete
>From 935e8a50f849cd8d13932bc3fcb41f5828c57b68 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 2 Nov 2020 19:51:38 -0300 >Subject: [PATCH] Bug 20212: Controller changes regression tests > >This patchset did a copy and paste of the objects->search helper inside >the controller, to handle a very special case that wasn't worth >generalizing: the fact that the biblio object (that this patchset makes >embeddable) is actually built from two tables, and we want to filter by >fields in both tables. > >This requires us to translate: >- Any filter reference to fields in biblioitems we allow to search on, through > an allow list. >- For filtering to work, we need to tweak the stashed 'embed' object so > the prefetch is done correctly > >This patchset also adds a new query parameter: only_active. It is used >to only request active orders (see the spec for more details). > >This patch adds tests for: >- Filtering by a column in bilbioitems (this implies correctly > prefetching the bilbio => biblioitems relation, and translating the > filtering parameter. >- Using the only_active query parameter to retrieve only active orders > >To test: >1. Apply this patchset >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/acquisitions_orders.t >=> SUCCESS: Tests pass! >3. Verify the tests check for the explained behaviours. >=> SUCCESS: They do! >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/api/v1/acquisitions_orders.t | 35 +++++++++++++++++++-- > 1 file changed, 33 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/api/v1/acquisitions_orders.t b/t/db_dependent/api/v1/acquisitions_orders.t >index 6335515a80..6700f0edb0 100755 >--- a/t/db_dependent/api/v1/acquisitions_orders.t >+++ b/t/db_dependent/api/v1/acquisitions_orders.t >@@ -24,6 +24,8 @@ use Test::Warn; > use t::lib::TestBuilder; > use t::lib::Mocks; > >+use JSON qw( encode_json ); >+ > use Koha::Acquisition::Orders; > use Koha::Database; > >@@ -35,7 +37,7 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > my $t = Test::Mojo->new('Koha::REST::V1'); > > subtest 'list() tests' => sub { >- plan tests => 8; >+ plan tests => 18; > > $schema->storage->txn_begin; > >@@ -48,11 +50,20 @@ subtest 'list() tests' => sub { > my $userid = $patron->userid; > > my $basket = $builder->build_object({ class => 'Koha::Acquisition::Baskets' }); >+ >+ my $biblio = $builder->build_sample_biblio; >+ my $biblioitem = $biblio->biblioitem; >+ $biblioitem->set({ isbn => 'SOMETHING' })->store; >+ > # Create test context > my $order = $builder->build_object( > { > class => 'Koha::Acquisition::Orders', >- value => { basketno => $basket->basketno, orderstatus => 'new' } >+ value => { >+ basketno => $basket->basketno, >+ orderstatus => 'new', >+ biblionumber => $biblio->biblionumber >+ } > } > ); > my $another_order = $order->unblessed; # create a copy of $order but make >@@ -98,6 +109,26 @@ subtest 'list() tests' => sub { > } > }; > >+ my $query = { "biblio.isbn" => { "-like" => "\%SOMETHING\%" } }; >+ >+ $t->get_ok( "//$userid:$password@/api/v1/acquisitions/orders?q=" . encode_json($query) => {'x-koha-embed' => 'biblio'} ) >+ ->status_is( 200, "Embeddig biblio.isbn doesn't make it explode" ) >+ ->json_has( "/0/biblio", "biblio object correctly embedded" ) >+ ->json_is( "/0/biblio/isbn", 'SOMETHING', 'Filtering by a biblioitems column works!' ); >+ >+ my $result = $t->get_ok( "//$userid:$password@/api/v1/acquisitions/orders?biblio_id=" . $biblio->biblionumber ) >+ ->status_is( 200 ); >+ >+ is( scalar @{ $result->tx->res->json}, 2, 'Two orders fetched' ); >+ >+ # Mark $another_order as cancelled >+ $another_order->set({ orderstatus => 'cancelled' })->store; >+ >+ $result = $t->get_ok( "//$userid:$password@/api/v1/acquisitions/orders?only_active=1&biblio_id=" . $biblio->biblionumber ) >+ ->status_is( 200, "only_active parameter accepted" ); >+ >+ is( scalar @{ $result->tx->res->json}, 1, 'Only one order is active' ); >+ > # Warn on unsupported query parameter > $t->get_ok( "//$userid:$password@/api/v1/acquisitions/orders?order_blah=blah" ) > ->status_is(400) >-- >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 20212
:
97545
|
97546
|
97547
|
97629
|
97630
|
97633
|
97634
|
97635
|
97745
|
98226
|
98230
|
98241
|
99724
|
99725
|
99727
|
100142
|
100475
|
100476
|
100477
|
100478
|
100552
|
100553
|
100554
|
100555
|
100600
|
100601
|
100602
|
100603
|
100605
|
100606
|
100643
|
101320
|
103684
|
103685
|
103686
|
103687
|
103688
|
109861
|
109862
|
109863
|
109864
|
109866
|
109867
|
109868
|
109869
|
109870
|
109936
|
110229
|
110234
|
110478
|
110482
|
111568
|
111569
|
112310
|
112521
|
112522
|
112523
|
112524
|
112686
|
112695
|
112698
|
112699
|
112700
|
112702
|
112703
|
112704
|
112705
|
112706
|
112868
|
112882
|
112987
|
113278
|
113279
|
114607
|
114608
|
114609
|
114610
|
114611
|
114612
|
114613
|
114614
|
114615
|
114616
|
114617
|
114942
|
114953
|
114954
|
114956
|
114959
|
114963
|
115050
|
115056
|
115057
|
115060
|
115062
|
115107
|
115108
|
115109
|
115817
|
115818
|
115819
|
115820
|
115821
|
115822
|
115886
|
115887
|
115888
|
115889
|
115890
|
115891
|
115892
|
115893
|
115894
|
115895
|
115896
|
115897
|
115898
|
115899
|
115900
|
115901
|
115902
|
115903
|
115904
|
115905
|
115906
|
115920
|
115921
|
115940
|
115941
|
115943
|
115944
|
115945
|
115946
|
115947
|
115948
|
115949
|
115950
|
115951
|
115952
|
115953
|
115954
|
115955
|
115956
|
115957
|
115958
|
115959
|
115960
|
115961
|
115962
|
115963
|
115964
|
115965
|
116139