Bug 38782

Summary: ERM eUsage related tests are failing
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: ERMAssignee: Pedro Amorim <pedro.amorim>
Status: Pushed to main --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, jonathan.druart, jonathan.field, martin.renvoize, matt.blenkinsop, pedro.amorim, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes failing ERM usage tests.
Version(s) released in:
25.05.00
Circulation function:
Bug Depends on: 36627    
Bug Blocks:    
Attachments: Bug 38782: Mock userenv->{number}
Bug 38782: Remove concat in background process
Bug 38782: Apply same fix for CounterFile.t
Bug 38782: Mock userenv->{number}
Bug 38782: Remove concat in background process
Bug 38782: Apply same fix for CounterFile.t
Bug 38782: Fix erm_custom_reports.t
Bug 38782: mock_userenv in API tests
Bug 38782: mock_userenv in API tests

Description Pedro Amorim 2024-12-24 10:36:22 UTC

    
Comment 1 Pedro Amorim 2024-12-24 10:42:24 UTC
Created attachment 175922 [details] [review]
Bug 38782: Mock userenv->{number}

prove t/db_dependent/Koha/BackgroundJobs/ErmSushiHarvester.t
Comment 2 Pedro Amorim 2024-12-24 10:42:27 UTC
Created attachment 175923 [details] [review]
Bug 38782: Remove concat in background process

The ud_provider->{report_type} is only defined on ->harvest_sushi, meaning it'll never be defined here.
We don't need this anyway. The filename should be the filename of the file being manually uploaded. We only need this concat logic for COUNTER files being generated by Koha following a SUSHI harvest, and that works.
This also gets rid of a warning when running the tests
Comment 3 Pedro Amorim 2024-12-24 10:47:16 UTC
Created attachment 175924 [details] [review]
Bug 38782: Apply same fix for CounterFile.t

prove t/db_dependent/Koha/ERM/EUsage/CounterFile.t
Comment 4 Tomás Cohen Arazi (tcohen) 2024-12-24 10:55:33 UTC
Created attachment 175925 [details] [review]
Bug 38782: Mock userenv->{number}

prove t/db_dependent/Koha/BackgroundJobs/ErmSushiHarvester.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Edit: tidy (tcohen)
Comment 5 Tomás Cohen Arazi (tcohen) 2024-12-24 10:55:36 UTC
Created attachment 175926 [details] [review]
Bug 38782: Remove concat in background process

The ud_provider->{report_type} is only defined on ->harvest_sushi, meaning it'll never be defined here.
We don't need this anyway. The filename should be the filename of the file being manually uploaded. We only need this concat logic for COUNTER files being generated by Koha following a SUSHI harvest, and that works.
This also gets rid of a warning when running the tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 6 Tomás Cohen Arazi (tcohen) 2024-12-24 10:55:38 UTC
Created attachment 175927 [details] [review]
Bug 38782: Apply same fix for CounterFile.t

prove t/db_dependent/Koha/ERM/EUsage/CounterFile.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Edit: tidy (tcohen)
Comment 7 Pedro Amorim 2024-12-24 10:58:33 UTC
Created attachment 175928 [details] [review]
Bug 38782: Fix erm_custom_reports.t

DRY superlibrarian declarion to top for all test methods.
Apply same fix from before i.e. mock_userenv

prove t/db_dependent/api/v1/erm_custom_reports.t
Comment 8 Pedro Amorim 2024-12-24 10:59:12 UTC
Thanks Tomas, I was missing a last (I think) test fix. Please double-check my last patch when you have the chance. Thanks!
Comment 9 Tomás Cohen Arazi (tcohen) 2024-12-24 11:09:38 UTC
(In reply to Pedro Amorim from comment #8)
> Thanks Tomas, I was missing a last (I think) test fix. Please double-check
> my last patch when you have the chance. Thanks!

I think it should happen inside a transaction.
Comment 10 Pedro Amorim 2024-12-24 11:15:15 UTC Comment hidden (obsolete)
Comment 11 Pedro Amorim 2024-12-24 11:15:53 UTC
(In reply to Tomás Cohen Arazi (tcohen) from comment #9)
> I think it should happen inside a transaction.

Fair. Patch amended.
Comment 12 Pedro Amorim 2024-12-24 11:16:45 UTC
Created attachment 175930 [details] [review]
Bug 38782: mock_userenv in API tests

Reorder logic slightly for each to only create the counter_file after the mock_userenv has taken place

prove t/db_dependent/api/v1/erm_custom_reports.t
Comment 13 Katrin Fischer 2024-12-27 14:02:12 UTC
Thanks Pedro!
Comment 14 Katrin Fischer 2024-12-27 14:20:26 UTC
Pushed for 25.05!

Well done everyone, thank you!