Bugzilla – Attachment 172110 Details for
Bug 37902
Timezone ignored when passing rfc3339 formatted date (search 'q')
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37902: Add tests
Bug-37902-Add-tests.patch (text/plain), 3.62 KB, created by
Kyle M Hall (khall)
on 2024-09-27 13:25:46 UTC
(
hide
)
Description:
Bug 37902: Add tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-09-27 13:25:46 UTC
Size:
3.62 KB
patch
obsolete
>From fd07d28e72c6cc0fdb948298e056f9143037df3c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 12 Sep 2024 12:01:58 +0200 >Subject: [PATCH] Bug 37902: Add tests > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 78 ++++++++++++++++++++++- > 1 file changed, 77 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index b0eebbd492c..c5e2dda2903 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -23,6 +23,7 @@ use Koha::AuthorisedValues; > use Koha::Cities; > use Koha::Biblios; > use Koha::Patrons; >+use Koha::DateUtils qw(dt_from_string); > > use Mojo::JSON qw(encode_json); > >@@ -139,7 +140,7 @@ get '/cities/:city_id/rs' => sub { > }; > > # The tests >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Mojo; > > use t::lib::Mocks; >@@ -963,3 +964,78 @@ subtest 'objects.find_rs helper' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'date handling' => sub { >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+ my $patron = >+ $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $patron->userid; >+ t::lib::Mocks::mock_userenv( { patron => $patron } ); >+ >+ my $now = dt_from_string(); >+ my $one_hour_ago = $now->clone->subtract( hours => 1 ); >+ my $one_day_ago = $now->clone->subtract( days => 1 ); >+ my $one_day_later = $now->clone->add( hours => 1 ); >+ >+ # one hour ago job >+ my $job_1 = $builder->build_object( >+ { >+ class => 'Koha::BackgroundJobs', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ enqueued_on => $one_hour_ago, >+ data => '{}', >+ } >+ } >+ ); >+ >+ # yesterday job >+ my $job_2 = $builder->build_object( >+ { >+ class => 'Koha::BackgroundJobs', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ enqueued_on => $one_day_ago, >+ data => '{}', >+ } >+ } >+ ); >+ >+ # tomorrow job >+ my $job_3 = $builder->build_object( >+ { >+ class => 'Koha::BackgroundJobs', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ enqueued_on => $one_day_later, >+ data => '{}', >+ } >+ } >+ ); >+ >+ my $t = Test::Mojo->new('Koha::REST::V1'); >+ my $q = encode_json( { enqueued_on => $one_hour_ago->rfc3339, borrowernumber => $patron->id } ); >+ $t->get_ok( "//$userid:$password@/api/v1/jobs?q=" . $q )->status_is(200)->json_is( '/0/job_id' => $job_1->id ); >+ my $response_count = scalar @{ $t->tx->res->json }; >+ is( $response_count, 1 ); >+ >+ $q = encode_json( >+ { >+ enqueued_on => [ { '>' => $now->rfc3339 }, { '=' => $one_hour_ago->rfc3339 } ], >+ borrowernumber => $patron->id >+ } >+ ); >+ $t->get_ok( "//$userid:$password@/api/v1/jobs?q=" . $q )->status_is(200)->json_is( '/0/job_id' => $job_1->id ) >+ ->json_is( '/1/job_id' => $job_3->id ); >+ $response_count = scalar @{ $t->tx->res->json }; >+ is( $response_count, 2 ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.5 (Apple Git-154)
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 37902
:
171389
|
171390
|
171391
|
171392
|
171402
|
171403
|
171515
|
171551
|
171652
|
171762
|
171763
|
171764
|
171765
|
171766
|
171767
|
171768
|
172105
|
172106
|
172107
|
172108
|
172109
| 172110 |
172111
|
172112