Bugzilla – Attachment 175930 Details for
Bug 38782
ERM eUsage related tests are failing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38782: mock_userenv in API tests
Bug-38782-mockuserenv-in-API-tests.patch (text/plain), 8.34 KB, created by
Pedro Amorim
on 2024-12-24 11:16:45 UTC
(
hide
)
Description:
Bug 38782: mock_userenv in API tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-12-24 11:16:45 UTC
Size:
8.34 KB
patch
obsolete
>From 7037f88a2e5f3347d82840eefb79024e35ea7ab0 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Tue, 24 Dec 2024 11:15:21 +0000 >Subject: [PATCH] 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 >--- > t/db_dependent/api/v1/erm_custom_reports.t | 116 +++++++++++---------- > 1 file changed, 60 insertions(+), 56 deletions(-) > >diff --git a/t/db_dependent/api/v1/erm_custom_reports.t b/t/db_dependent/api/v1/erm_custom_reports.t >index 1317c61761e..fcb7eba1b02 100755 >--- a/t/db_dependent/api/v1/erm_custom_reports.t >+++ b/t/db_dependent/api/v1/erm_custom_reports.t >@@ -50,20 +50,6 @@ subtest "monthly_report" => sub { > > $schema->storage->txn_begin; > >- # Run a harvest to populate the database with data >- my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >- my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >- >- $usage_data_provider->counter_files( >- [ >- { >- usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >- file_content => $counter_file, >- filename => "Test_TR_J1", >- } >- ] >- ); >- > my $librarian = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -73,6 +59,7 @@ subtest "monthly_report" => sub { > my $password = 'thePassword123'; > $librarian->set_password( { password => $password, skip_validation => 1 } ); > my $userid = $librarian->userid; >+ t::lib::Mocks::mock_userenv( { number => $userid } ); > > my $patron = $builder->build_object( > { >@@ -84,6 +71,20 @@ subtest "monthly_report" => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > my $unauth_userid = $patron->userid; > >+ # Run a harvest to populate the database with data >+ my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >+ my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >+ >+ $usage_data_provider->counter_files( >+ [ >+ { >+ usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >+ file_content => $counter_file, >+ filename => "Test_TR_J1", >+ } >+ ] >+ ); >+ > # Unauthorized access > $t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/monthly_report/title")->status_is(403); > >@@ -148,20 +149,6 @@ subtest "yearly_report" => sub { > > $schema->storage->txn_begin; > >- # Run a harvest to populate the database with data >- my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >- my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >- >- $usage_data_provider->counter_files( >- [ >- { >- usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >- file_content => $counter_file, >- filename => "Test_TR_J1", >- } >- ] >- ); >- > my $librarian = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -171,6 +158,7 @@ subtest "yearly_report" => sub { > my $password = 'thePassword123'; > $librarian->set_password( { password => $password, skip_validation => 1 } ); > my $userid = $librarian->userid; >+ t::lib::Mocks::mock_userenv( { number => $userid } ); > > my $patron = $builder->build_object( > { >@@ -182,6 +170,20 @@ subtest "yearly_report" => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > my $unauth_userid = $patron->userid; > >+ # Run a harvest to populate the database with data >+ my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >+ my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >+ >+ $usage_data_provider->counter_files( >+ [ >+ { >+ usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >+ file_content => $counter_file, >+ filename => "Test_TR_J1", >+ } >+ ] >+ ); >+ > # Unauthorized access > $t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/yearly_report/title")->status_is(403); > >@@ -237,20 +239,6 @@ subtest "metric_types_report" => sub { > > $schema->storage->txn_begin; > >- # Run a harvest to populate the database with data >- my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >- my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >- >- $usage_data_provider->counter_files( >- [ >- { >- usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >- file_content => $counter_file, >- filename => "Test_TR_J1", >- } >- ] >- ); >- > my $librarian = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -260,6 +248,7 @@ subtest "metric_types_report" => sub { > my $password = 'thePassword123'; > $librarian->set_password( { password => $password, skip_validation => 1 } ); > my $userid = $librarian->userid; >+ t::lib::Mocks::mock_userenv( { number => $userid } ); > > my $patron = $builder->build_object( > { >@@ -271,6 +260,20 @@ subtest "metric_types_report" => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > my $unauth_userid = $patron->userid; > >+ # Run a harvest to populate the database with data >+ my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >+ my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >+ >+ $usage_data_provider->counter_files( >+ [ >+ { >+ usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >+ file_content => $counter_file, >+ filename => "Test_TR_J1", >+ } >+ ] >+ ); >+ > # Unauthorized access > $t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/metric_types_report/title")->status_is(403); > >@@ -332,20 +335,6 @@ subtest "provider_rollup_report" => sub { > > $schema->storage->txn_begin; > >- # Run a harvest to populate the database with data >- my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >- my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >- >- $usage_data_provider->counter_files( >- [ >- { >- usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >- file_content => $counter_file, >- filename => "Test_TR_J1", >- } >- ] >- ); >- > my $librarian = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -355,6 +344,7 @@ subtest "provider_rollup_report" => sub { > my $password = 'thePassword123'; > $librarian->set_password( { password => $password, skip_validation => 1 } ); > my $userid = $librarian->userid; >+ t::lib::Mocks::mock_userenv( { number => $userid } ); > > my $patron = $builder->build_object( > { >@@ -366,6 +356,20 @@ subtest "provider_rollup_report" => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > my $unauth_userid = $patron->userid; > >+ # Run a harvest to populate the database with data >+ my $usage_data_provider = $builder->build_object( { class => 'Koha::ERM::EUsage::UsageDataProviders' } ); >+ my $counter_file = $sushi_counter_TR_J1->get_COUNTER_from_SUSHI; >+ >+ $usage_data_provider->counter_files( >+ [ >+ { >+ usage_data_provider_id => $usage_data_provider->erm_usage_data_provider_id, >+ file_content => $counter_file, >+ filename => "Test_TR_J1", >+ } >+ ] >+ ); >+ > # Unauthorized access > $t->get_ok("//$unauth_userid:$password@/api/v1/erm/eUsage/provider_rollup_report/title")->status_is(403); > >-- >2.39.5
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 38782
:
175922
|
175923
|
175924
|
175925
|
175926
|
175927
|
175928
|
175929
| 175930