Bug 32340 - Several tests failing for t/db_dependent/Reserves.t
Summary: Several tests failing for t/db_dependent/Reserves.t
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Emmi Takkinen
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-24 11:34 UTC by Emmi Takkinen
Modified: 2024-01-12 14:32 UTC (History)
2 users (show)

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


Attachments
Bug 32340: Fix t/db_dependent/Reserves.t tests (3.22 KB, patch)
2023-06-30 12:36 UTC, Emmi Takkinen
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emmi Takkinen 2022-11-24 11:34:01 UTC
Runnig prove t/db_dependent/Reserves.t gives following results on master:

t/db_dependent/Reserves.t .. 1/77 Failed to load Koha::Plugin::Fi::KohaSuomi::OKMStats: Could not find or check module 'Koha::Plugin::Fi::KohaSuomi::OKMStats' at /home/emmi/Koha/Koha/Plugins.pm line 124.
t/db_dependent/Reserves.t .. 2/77 No reserves HOLD letter transported by print at /home/emmi/Koha/C4/Letters.pm line 584.
Could not find a letter called 'HOLD' for print in the 'reserves' module at /home/emmi/Koha/C4/Reserves.pm line 1915.
No reserves HOLD_CANCELLATION letter transported by email at /home/emmi/Koha/C4/Letters.pm line 584.
No reserves HOLD letter transported by print at /home/emmi/Koha/C4/Letters.pm line 584.
Could not find a letter called 'HOLD' for print in the 'reserves' module at /home/emmi/Koha/C4/Reserves.pm line 1915.

#   Failed test 'patron notified when item set to waiting'
#   at t/db_dependent/Reserves.t line 416.
#          got: '0'
#     expected: '1'

#   Failed test 'patron not notified a second time (bug 11445)'
#   at t/db_dependent/Reserves.t line 421.
#          got: '0'
#     expected: '1'
No circulation HOLD_SLIP letter transported by email at /home/emmi/Koha/C4/Letters.pm line 584.

#   Failed test 'can successfully generate hold slip (bug 10949)'
#   at t/db_dependent/Reserves.t line 433.
No reserves HOLD letter transported by print at /home/emmi/Koha/C4/Letters.pm line 584.
Could not find a letter called 'HOLD' for print in the 'reserves' module at /home/emmi/Koha/C4/Reserves.pm line 1915.
No reserves HOLD letter transported by print at /home/emmi/Koha/C4/Letters.pm line 584.
Could not find a letter called 'HOLD' for print in the 'reserves' module at /home/emmi/Koha/C4/Reserves.pm line 1915.
t/db_dependent/Reserves.t .. 41/77 No reserves HOLD letter transported by print at /home/emmi/Koha/C4/Letters.pm line 584.
Could not find a letter called 'HOLD' for print in the 'reserves' module at /home/emmi/Koha/C4/Reserves.pm line 1915.
t/db_dependent/Reserves.t .. 69/77 
    #   Failed test 'Item not available for item-level hold because no effective item type'
    #   at t/db_dependent/Reserves.t line 1469.
    # Looks like you failed 1 test of 2.

#   Failed test 'IsAvailableForItemLevelRequest() tests'
#   at t/db_dependent/Reserves.t line 1475.
t/db_dependent/Reserves.t .. 75/77 # Looks like you failed 4 tests of 77.
t/db_dependent/Reserves.t .. Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/77 subtests 

Test Summary Report
-------------------
t/db_dependent/Reserves.t (Wstat: 1024 Tests: 77 Failed: 4)
  Failed tests:  26-27, 29, 73
  Non-zero exit status: 4
Files=1, Tests=77,  6 wallclock secs ( 0.03 usr  0.00 sys +  5.23 cusr  0.37 csys =  5.63 CPU)
Result: FAIL
Comment 1 Emmi Takkinen 2022-11-24 12:30:53 UTC
So it seems I'm missing few notices from my test environment. I can understand that tests assume that HOLD and HOLD_SLIP are present, they are included in sample notices. But I can't find any traces of this HOLD_CANCELLATION notice, are we missing it from sample_notices.yml?
Comment 2 Lari Taskula 2023-02-10 12:44:20 UTC
I noticed the same warning for HOLD_CANCELLATION and figured out it was removed in Bug 27103. But I believe this warning can be ignored.
Comment 3 Katrin Fischer 2023-06-10 22:26:25 UTC
Hi Emmi, the tests pass for me on master with the sample database. I believe the sample data is assumed.
Comment 4 Emmi Takkinen 2023-06-14 05:37:59 UTC
(In reply to Katrin Fischer from comment #3)
> Hi Emmi, the tests pass for me on master with the sample database. I believe
> the sample data is assumed.

Yep, but my sample data is no longer contains HOLD_CANCELLATION letter, I've probably deleted it at some point. Added it manually and tests no longer complain it missing. However I'm getting a whole new batch of errors now:

t/db_dependent/Reserves.t .. 2/77 Use of uninitialized value $email in string ne at /home/emmi/Koha/Koha/Patron.pm line 1445.
Use of uninitialized value $email in string ne at /home/emmi/Koha/Koha/Patron.pm line 1445.
Use of uninitialized value $email in string ne at /home/emmi/Koha/Koha/Patron.pm line 1445.
Use of uninitialized value $email in string ne at /home/emmi/Koha/Koha/Patron.pm line 1445.
Use of uninitialized value $email in string ne at /home/emmi/Koha/Koha/Patron.pm line 1445.
Use of uninitialized value $email in string ne at /home/emmi/Koha/Koha/Patron.pm line 1445.
Can't call method "can_edit_items_from" on an undefined value at /home/emmi/Koha/Koha/Item.pm line 298.
Comment 5 Emmi Takkinen 2023-06-29 11:45:55 UTC
(In reply to Emmi Takkinen from comment #4)
> (In reply to Katrin Fischer from comment #3)
> > Hi Emmi, the tests pass for me on master with the sample database. I believe
> > the sample data is assumed.
> 
> Yep, but my sample data is no longer contains HOLD_CANCELLATION letter, I've
> probably deleted it at some point. Added it manually and tests no longer
> complain it missing. However I'm getting a whole new batch of errors now:
> 
> t/db_dependent/Reserves.t .. 2/77 Use of uninitialized value $email in
> string ne at /home/emmi/Koha/Koha/Patron.pm line 1445.
> Use of uninitialized value $email in string ne at
> /home/emmi/Koha/Koha/Patron.pm line 1445.
> Use of uninitialized value $email in string ne at
> /home/emmi/Koha/Koha/Patron.pm line 1445.
> Use of uninitialized value $email in string ne at
> /home/emmi/Koha/Koha/Patron.pm line 1445.
> Use of uninitialized value $email in string ne at
> /home/emmi/Koha/Koha/Patron.pm line 1445.
> Use of uninitialized value $email in string ne at
> /home/emmi/Koha/Koha/Patron.pm line 1445.
> Can't call method "can_edit_items_from" on an undefined value at
> /home/emmi/Koha/Koha/Item.pm line 298.

Hmm, this could happen because we don't mock user environment somewhere in the code. I just ran into similar problem in bug 34152.
Comment 6 Emmi Takkinen 2023-06-30 07:40:27 UTC
Yep mocking user environment for manager does the trick.

Also got this one as a new:

t/db_dependent/Reserves.t .. 73/77 
    #   Failed test 'Reserve date set 1 year from today'
    #   at t/db_dependent/Reserves.t line 1758.
    #          got: '2388-06-30'
    #     expected: '2024-06-29'
    # Looks like you failed 1 test of 2.

#   Failed test 'DefaultHoldExpiration tests'
#   at t/db_dependent/Reserves.t line 1761.
# Looks like you failed 2 tests of 77.

There's a typo in this line:

t::lib::Mocks::mock_preference( 'DefaultHoldExpirationUnitOfTime', 'days;' );
Comment 7 Emmi Takkinen 2023-06-30 12:36:55 UTC
Created attachment 152903 [details] [review]
Bug 32340: Fix t/db_dependent/Reserves.t tests

This patch does following fixes:
- Get rid of "Use of uninitialized value $email in string ne" warning
by adding email for test patrons
-  Prevent "Can't call method "can_edit_items_from" on an undefined
value" by adding mock manager patron
- Fix typos in DefaultHoldExpirationdate tests

To test:
1) Run prove t/db_dependent/Reserves.t.
-> Tests should fail.
2) Apply this patch.
3) Rerun prove t/db_dependent/Reserves.t.
-> Success!

Sponsored-by: Koha-Suomi Oy
Comment 8 Matthias Le Gac 2024-01-12 14:32:09 UTC
After I apply the patch the test doesn't pass.

t/db_dependent/Reserves.t .. 5/77 No reserves HOLD_CANCELLATION letter transported by email at /inlibro/git/koha-master-dev-matthias/C4/Letters.pm line 603.
t/db_dependent/Reserves.t .. 50/77 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_master_dev_matthias`.`accountlines`, CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type_code`) REFERENCES `account_debit_types` (`code`) ON UPDATE CASCADE) at /inlibro/git/koha-master-dev-matthias/Koha/Object.pm line 170
    # No tests run!

#   Failed test 'No tests run for subtest "ChargeReserveFee tests"'
#   at t/db_dependent/Reserves.t line 983.
Exception 'Koha::Exceptions::Account::UnrecognisedType' thrown 'Type of debit not recognised'
# Looks like your test exited with 255 just after 62.
t/db_dependent/Reserves.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 16/77 subtests 

Test Summary Report
-------------------
t/db_dependent/Reserves.t (Wstat: 65280 Tests: 62 Failed: 1)
  Failed test:  62
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 77 tests but ran 62.
Files=1, Tests=62,  3 wallclock secs ( 0.03 usr  0.00 sys +  3.07 cusr  0.16 csys =  3.26 CPU)
Result: FAIL