From 074b98579ba0a23571ab57bedc31885175ba00c5 Mon Sep 17 00:00:00 2001 From: Marina Gourtovaia Date: Fri, 17 May 2024 10:12:43 +0100 Subject: [PATCH] Added a default dnap-ssr email recipient ... to a list of recipients of emails for subscribers. This type of email is sent for every eligible event. --- lib/npg_tracking/report/event2subscribers.pm | 3 ++- t/80-npg_tracking-report-event2subscribers.t | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/npg_tracking/report/event2subscribers.pm b/lib/npg_tracking/report/event2subscribers.pm index 49a7a78e..1d4c6b08 100644 --- a/lib/npg_tracking/report/event2subscribers.pm +++ b/lib/npg_tracking/report/event2subscribers.pm @@ -21,6 +21,7 @@ Readonly::Scalar my $TEMPLATE_EXT => q[.tt2]; ## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars) Readonly::Scalar my $DEFAULT_RECIPIENT_HOST => q[@sanger.ac.uk]; ## use critic +Readonly::Array my @DEFAULT_RECIPIENTS => qw[dnap-ssr]; Readonly::Scalar my $DEFAULT_AUTHOR => q[srpipe]; Readonly::Scalar my $MLWH_DRIVER_TYPE => q[ml_warehouse_fc_cache]; @@ -159,7 +160,7 @@ sub username2email_address { sub _subscribers { my $self = shift; my $group = $self->_is_instrument_event ? q[engineers] : q[events]; - my @subscribers = (); + my @subscribers = @DEFAULT_RECIPIENTS; my $schema = $self->event_entity->result_source->schema; my $group_row = $schema->resultset('Usergroup')->search( {groupname => $group, iscurrent => 1})->next(); diff --git a/t/80-npg_tracking-report-event2subscribers.t b/t/80-npg_tracking-report-event2subscribers.t index 39264a9f..4a363555 100644 --- a/t/80-npg_tracking-report-event2subscribers.t +++ b/t/80-npg_tracking-report-event2subscribers.t @@ -145,7 +145,8 @@ subtest 'run status event' => sub { ok ($e->dry_run, 'dry_run mode'); is ($e->report_author(), $report_author, 'report author'); is ($e->template_name(), 'run_or_lane2subscribers', 'template name'); - is_deeply ($e->_subscribers(), [qw(acu4@some.com cu1@sanger.ac.uk cu2@sanger.ac.uk)], + is_deeply ($e->_subscribers(), + [qw(acu4@some.com cu1@sanger.ac.uk cu2@sanger.ac.uk dnap-ssr@sanger.ac.uk)], 'correct ordered list of subscribers'); is ($e->report_short(), 'Run 21915 was assigned status "run pending"', 'short report text'); @@ -205,7 +206,8 @@ subtest 'instrument status event' => sub { isa_ok ($e, 'npg_tracking::report::event2subscribers'); is ($e->report_author(), $report_author, 'report author'); is ($e->template_name(), 'instrument', 'template name'); - is_deeply ($e->_subscribers(), [qw(acu4@some.com cu2@sanger.ac.uk cu3@sanger.ac.uk)], + is_deeply ($e->_subscribers(), + [qw(acu4@some.com cu2@sanger.ac.uk cu3@sanger.ac.uk dnap-ssr@sanger.ac.uk)], 'correct ordered list of subscribers'); is ($e->report_short(), 'Instrument HS8 status changed to "wash performed"', 'short report text'); warning_is {$e->lims} undef, 'no warning about LIMs driver'; @@ -260,7 +262,8 @@ subtest 'run annotation event' => sub { ok ($e->dry_run, 'dry_run mode'); is ($e->report_author(), $report_author, 'report author'); is ($e->template_name(), 'run_or_lane2subscribers', 'template name'); - is_deeply ($e->_subscribers(), [qw(acu4@some.com cu1@sanger.ac.uk cu2@sanger.ac.uk)], + is_deeply ($e->_subscribers(), + [qw(acu4@some.com cu1@sanger.ac.uk cu2@sanger.ac.uk dnap-ssr@sanger.ac.uk)], 'correct ordered list of subscribers'); is ($e->report_short(), 'Run 21915 annotated by joe_loader', 'short report text'); is (scalar @{$e->lims}, 8, 'Retrieved LIMs object'); @@ -305,7 +308,8 @@ subtest 'runlane annotation event' => sub { ok ($e->dry_run, 'dry_run mode'); is ($e->report_author(), $report_author, 'report author'); is ($e->template_name(), 'run_or_lane2subscribers', 'template name'); - is_deeply ($e->_subscribers(), [qw(acu4@some.com cu1@sanger.ac.uk cu2@sanger.ac.uk)], + is_deeply ($e->_subscribers(), + [qw(acu4@some.com cu1@sanger.ac.uk cu2@sanger.ac.uk dnap-ssr@sanger.ac.uk)], 'correct ordered list of subscribers'); is ($e->report_short(), 'Run 21915 lane 2 annotated by joe_loader', 'short report text'); is (scalar @{$e->lims}, 1, 'Retrieved LIMs object'); @@ -350,7 +354,8 @@ subtest 'instrument annotation event' => sub { isa_ok ($e, 'npg_tracking::report::event2subscribers'); is ($e->report_author(), $report_author, 'report author'); is ($e->template_name(), 'instrument', 'template name'); - is_deeply ($e->_subscribers(), [qw(acu4@some.com cu2@sanger.ac.uk cu3@sanger.ac.uk)], + is_deeply ($e->_subscribers(), + [qw(acu4@some.com cu2@sanger.ac.uk cu3@sanger.ac.uk dnap-ssr@sanger.ac.uk)], 'correct ordered list of subscribers'); is ($e->report_short(), 'Instrument HS8 annotated by joe_loader', 'short report text'); warning_is {$e->lims} undef, 'no warning about LIMs driver';