Bug 34489 - Koha/Patrons.t: Subtests get_age and is_valid_age do not pass in another timezone
Summary: Koha/Patrons.t: Subtests get_age and is_valid_age do not pass in another time...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Marcel de Rooy
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-07 12:47 UTC by Marcel de Rooy
Modified: 2024-07-04 20:40 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.05,22.11.11


Attachments
Bug 34489: Testing (1.29 KB, patch)
2023-08-08 14:09 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34489: Fix timezone problem in Patrons.t (1.71 KB, patch)
2023-09-27 12:17 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34489: Fix timezone problem in Patrons.t (1.73 KB, patch)
2023-09-29 12:14 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2023-08-07 12:47:49 UTC
Running in Amsterdam TZ gives:

# Subtest: get_age
    not ok 5 - Today=2020-02-28, dob=2004-02-28, should be 16
    #   Failed test 'Today=2020-02-28, dob=2004-02-28, should be 16'
    #   at t/db_dependent/Koha/Patrons.t line 814.
    #          got: '15'
    #     expected: '16'
    not ok 9 - Today=2020-02-28, dob=2002-02-28, should be 18
    not ok 16 - Today=2020-02-29, dob=2004-02-29, should be 16
    not ok 19 - Today=2020-03-01, dob=2002-03-01, should be 18
    not ok 23 - Today=2020-03-01, dob=2004-03-01, should be 16
    not ok 25 - Today=2019-01-31, dob=2001-01-31, should be 18
    not ok 28 - Today=2019-01-31, dob=2003-01-31, should be 16
    # Looks like you failed 7 tests of 31.
not ok 18 - get_age
# Subtest: is_valid_age
    not ok 2 - Today=2020-02-28, dob=2009-02-28, is 11, should be valid=0 in category AGE_5_10
    #   Failed test 'Today=2020-02-28, dob=2009-02-28, is 11, should be valid=0 in category AGE_5_10'
    #   at t/db_dependent/Koha/Patrons.t line 893.
    #          got: '1'
    #     expected: '0'
    not ok 7 - Today=2020-02-28, dob=2015-02-28, is 5, should be valid=1 in category AGE_5_10
    #   Failed test 'Today=2020-02-28, dob=2015-02-28, is 5, should be valid=1 in category AGE_5_10'
    #   at t/db_dependent/Koha/Patrons.t line 893.
    #          got: '0'
    #     expected: '1'
    # Looks like you failed 2 tests of 10.
not ok 19 - is_valid_age

Adding a tzset to UTC in the test as a workaround. Bug 25621 suggests patching DateUtils.pm as a definitive solution?
Comment 1 Marcel de Rooy 2023-08-08 12:37:09 UTC
(In reply to Marcel de Rooy from comment #0)
> Adding a tzset to UTC in the test as a workaround. Bug 25621 suggests
> patching DateUtils.pm as a definitive solution?

No tzset is not satisfactory. What about removing floating from get_age ?
Comment 2 Marcel de Rooy 2023-08-08 14:09:04 UTC
Created attachment 154318 [details] [review]
Bug 34489: Testing
Comment 3 Marcel de Rooy 2023-08-08 14:11:32 UTC
dt_from_string is rather weird with time zones. Why not pass now in server_tz ?
See testing patch too.

Some tests in DateUtils.t are just wrong. Try testing in Pacific/Fiji. Having a difference of 13 hours, will make one of the rfc3339 tests fail. The test is wrong.
Comment 4 Marcel de Rooy 2023-08-09 13:07:10 UTC
This might be in the same category:

t/db_dependent/api/v1/patrons.t
            not ok 6 - Filtering by date-time works
            #   Failed test 'Filtering by date-time works'
            #   at t/db_dependent/api/v1/patrons.t line 123.
            #          got: undef
            #     expected: '2253'

my $last_seen_rfc3339 = $last_seen . "z";
$t->get_ok("//$userid:$password@/api/v1/patrons?last_seen=" . $last_seen_rfc3339 . "&cardnumber=" . $patron->cardnumber)
>status_is(200)
>json_is( '/0/patron_id' => $patron->id, 'Filtering by date-time works' );
Comment 5 Marcel de Rooy 2023-09-27 12:09:30 UTC
Comment on attachment 154318 [details] [review]
Bug 34489: Testing

Will be following same approach as on bug 34930 now.
Comment 6 Marcel de Rooy 2023-09-27 12:17:45 UTC
Created attachment 156285 [details] [review]
Bug 34489: Fix timezone problem in Patrons.t

See also bug 34930. Using same approach.

Test plan:
export TZ='Europe/Amsterdam'
prove t/db_dependent/Koha/Patrons.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Marcel de Rooy 2023-09-27 12:18:05 UTC
Trivial: Self SO
Comment 8 Katrin Fischer 2023-09-29 12:14:13 UTC
Created attachment 156386 [details] [review]
Bug 34489: Fix timezone problem in Patrons.t

See also bug 34930. Using same approach.

Test plan:
export TZ='Europe/Amsterdam'
prove t/db_dependent/Koha/Patrons.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 9 Tomás Cohen Arazi 2023-10-03 12:55:20 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 10 Fridolin Somers 2023-10-05 19:18:40 UTC
Pushed to 23.05.x for 23.05.05
Comment 11 Jacob O'Mara 2023-10-17 13:37:42 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x