Bugzilla – Attachment 173874 Details for
Bug 32440
Allow selective deletion of statistics entries based on type by cleanup_database
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32440: Add missing unit test for Koha::Statistic->pseudonymize()
Bug-32440-Add-missing-unit-test-for-KohaStatistic-.patch (text/plain), 3.33 KB, created by
Andrew Fuerste-Henry
on 2024-11-01 13:34:07 UTC
(
hide
)
Description:
Bug 32440: Add missing unit test for Koha::Statistic->pseudonymize()
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2024-11-01 13:34:07 UTC
Size:
3.33 KB
patch
obsolete
>From 03e2a6250455654176b51b31eded7911118121c8 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Tue, 15 Oct 2024 16:47:36 +0000 >Subject: [PATCH] Bug 32440: Add missing unit test for > Koha::Statistic->pseudonymize() > >To test: >1. prove t/db_dependent/Koha/Statistic.t > >Observe > >Subtest: pseudonymize() tests > 1..6 > ok 1 - some pseudonymization_types are defined > ok 2 - Background job enqueued for type renew > ok 3 - Background job enqueued for type issue > ok 4 - Background job enqueued for type return > ok 5 - Background job enqueued for type onsite_checkout > ok 6 - Background job not enqueued for type not_gonna_pseudo >ok 2 - pseudonymize() tests > >Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> >--- > t/db_dependent/Koha/Statistic.t | 68 ++++++++++++++++++++++++++++++++- > 1 file changed, 67 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Statistic.t b/t/db_dependent/Koha/Statistic.t >index 1146c3330d..000ecb2133 100755 >--- a/t/db_dependent/Koha/Statistic.t >+++ b/t/db_dependent/Koha/Statistic.t >@@ -17,7 +17,9 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::MockModule; >+use Test::More tests => 2; >+use Test::Warn; > > use Koha::DateUtils qw(dt_from_string); > use Koha::Statistics; >@@ -56,3 +58,67 @@ subtest 'new() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'pseudonymize() tests' => sub { >+ >+ my @pseudonymization_types = qw(renew issue return onsite_checkout); >+ plan tests => scalar(@pseudonymization_types) + 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $not_type = 'not_gonna_pseudo'; >+ >+ my $pseudo_background = Test::MockModule->new('Koha::BackgroundJob::PseudonymizeStatistic'); >+ $pseudo_background->mock( enqueue => sub { warn "Called" } ); >+ >+ my @statistics = (); >+ >+ ok( scalar(@pseudonymization_types) > 0, 'some pseudonymization_types are defined' ); >+ >+ my $sub_days = 0; # TestBuilder does not handle many rows of Koha::Statistics very intuitively >+ foreach my $type (@pseudonymization_types) { >+ push( >+ @statistics, >+ $builder->build_object( >+ { >+ class => 'Koha::Statistics', >+ value => { >+ datetime => $dtf->format_datetime( dt_from_string()->subtract( days => $sub_days ) ), >+ type => $type, >+ }, >+ } >+ ) >+ ); >+ $sub_days++; >+ } >+ >+ push( >+ @statistics, >+ $builder->build_object( >+ { >+ class => 'Koha::Statistics', >+ value => { >+ datetime => $dtf->format_datetime( dt_from_string()->subtract( days => 7 ) ), >+ type => $not_type, >+ }, >+ } >+ ) >+ ); >+ >+ foreach my $statistic (@statistics) { >+ my $type = $statistic->type; >+ if ( $type ne $not_type ) { >+ warnings_are { >+ $statistic->pseudonymize(); >+ } >+ ["Called"], "Background job enqueued for type $type"; >+ } else { >+ warnings_are { >+ $statistic->pseudonymize(); >+ } >+ undef, "Background job not enqueued for type $type"; >+ } >+ } >+ >+ $schema->storage->txn_rollback; >+}; >\ No newline at end of file >-- >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 32440
:
172790
|
172791
| 173874 |
173875