aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm15
-rw-r--r--perllib/FixMyStreet/SendReport.pm1
-rw-r--r--perllib/FixMyStreet/SendReport/Barnet.pm11
-rw-r--r--perllib/FixMyStreet/TestMech.pm1
-rw-r--r--t/app/controller/report_updates.t20
5 files changed, 40 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 30ad41704..8ec68a440 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -234,6 +234,7 @@ sub send_reports {
my $send_report = FixMyStreet::SendReport->new();
my $senders = $send_report->get_senders;
+ my %sending_skipped_by_method;
while (my $row = $unsent->next) {
@@ -320,7 +321,10 @@ sub send_reports {
}
$reporters{ $sender } ||= $sender->new();
- unless ( $reporters{ $sender }->should_skip( $row ) ) {
+ if ( $reporters{ $sender }->should_skip( $row ) ) {
+ $sending_skipped_by_method{ $sender }++ if
+ $reporters{ $sender }->skipped;
+ } else {
push @dear, $name;
$reporters{ $sender }->add_council( $council, $name );
}
@@ -408,6 +412,15 @@ sub send_reports {
print $notgot{$e}{$c} . " problem, to $e category $c (" . $note{$e}{$c}. ")\n";
}
}
+ if (keys %sending_skipped_by_method) {
+ my $c = 0;
+ print "\nProblem reports that send-reports did not attempt to send the following:\n";
+ foreach my $send_method (sort keys %sending_skipped_by_method) {
+ printf " %-24s %4d\n", "$send_method:", $sending_skipped_by_method{$send_method};
+ $c+=$sending_skipped_by_method{$send_method};
+ }
+ printf " %-24s %4d\n", "Total:", $c;
+ }
}
}
diff --git a/perllib/FixMyStreet/SendReport.pm b/perllib/FixMyStreet/SendReport.pm
index 426e8eefe..915fe4a20 100644
--- a/perllib/FixMyStreet/SendReport.pm
+++ b/perllib/FixMyStreet/SendReport.pm
@@ -11,6 +11,7 @@ has 'councils' => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
has 'to' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
has 'success' => ( is => 'rw', isa => 'Bool', default => 0 );
has 'error' => ( is => 'rw', isa => 'Str', default => '' );
+has 'skipped' => ( 'is' => 'rw', isa => 'Str', default => '' );
sub should_skip {
diff --git a/perllib/FixMyStreet/SendReport/Barnet.pm b/perllib/FixMyStreet/SendReport/Barnet.pm
index 72c279282..3eb8d2048 100644
--- a/perllib/FixMyStreet/SendReport/Barnet.pm
+++ b/perllib/FixMyStreet/SendReport/Barnet.pm
@@ -5,6 +5,7 @@ use Moose;
BEGIN { extends 'FixMyStreet::SendReport'; }
use BarnetInterfaces::service::ZLBB_SERVICE_ORDER;
+use Encode;
use Utils;
use mySociety::Config;
use mySociety::Web qw(ent);
@@ -14,7 +15,6 @@ use constant SEND_FAIL_RETRIES_CUTOFF => 3;
# specific council numbers
use constant COUNCIL_ID_BARNET => 2489;
-
use constant MAX_LINE_LENGTH => 132;
sub should_skip {
@@ -29,11 +29,12 @@ sub should_skip {
$err_msg = "skipped: problem id=" . $problem->id . " send$council_name has failed "
. $problem->send_fail_count . " times, cutoff is " . SEND_FAIL_RETRIES_CUTOFF;
+ $self->skipped( $err_msg );
+
return 1;
}
}
-# currently just blind copy of construct_easthants_message
sub construct_message {
my %h = @_;
my $message = <<EOF;
@@ -55,7 +56,7 @@ sub send {
my %h = %$h;
- $h{message} = construct_barnet_message(%h);
+ $h{message} = construct_message(%h);
my $return = 1;
my $err_msg = "";
@@ -83,6 +84,10 @@ sub send {
$interface->set_proxy($council_config->endpoint);
# Barnet web service doesn't like namespaces in the elements so use a prefix
$interface->set_prefix('urn');
+ # uncomment these lines to print XML that will be sent rather
+ # than connecting to the endpoint
+ #$interface->outputxml(1);
+ #$interface->no_dispatch(1);
} else {
die "Barnet webservice FAIL: looks like you're missing some config data: no endpoint (URL) found for area_id=" . COUNCIL_ID_BARNET;
}
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index 7daf01f56..dc42c1aba 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -225,6 +225,7 @@ sub form_errors {
my $result = scraper {
process 'div.form-error', 'errors[]', 'TEXT';
process 'p.form-error', 'errors[]', 'TEXT';
+ process 'p.error', 'errors[]', 'TEXT';
}
->scrape( $mech->response );
return $result->{errors} || [];
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t
index 9c2b0861b..0337a881b 100644
--- a/t/app/controller/report_updates.t
+++ b/t/app/controller/report_updates.t
@@ -872,7 +872,11 @@ for my $test (
is_deeply $values, $test->{initial_values}, 'initial form values';
- is $mech->extract_problem_banner->{text}, $test->{initial_banner}, 'initial banner';
+ if ( !defined( $test->{initial_banner} ) ) {
+ is $mech->extract_problem_banner->{text}, undef, 'initial banner';
+ } else {
+ like $mech->extract_problem_banner->{text}, qr/@{[ $test->{initial_banner} ]}/i, 'initial banner';
+ }
$mech->submit_form_ok(
{
@@ -883,7 +887,11 @@ for my $test (
is $mech->uri->path, "/report/" . $report_id, "redirected to report page";
- is $mech->extract_problem_banner->{text}, $test->{endstate_banner}, 'submitted banner';
+ if ( !defined( $test->{endstate_banner} ) ) {
+ is $mech->extract_problem_banner->{text}, undef, 'endstate banner';
+ } else {
+ like $mech->extract_problem_banner->{text}, qr/@{[ $test->{endstate_banner} ]}/i, 'endstate banner';
+ }
$mech->email_count_is(0);
@@ -1029,8 +1037,12 @@ foreach my $test (
is_deeply $values, $test->{initial_values}, 'initial form values';
- is $mech->extract_problem_banner->{text}, $test->{initial_banner},
- 'initial banner';
+ if ( !defined( $test->{initial_banner} ) ) {
+ is $mech->extract_problem_banner->{text}, undef, 'initial banner';
+ } else {
+ like $mech->extract_problem_banner->{text}, qr/@{[ $test->{initial_banner} ]}/i,
+ 'initial banner';
+ }
$mech->submit_form_ok( { with_fields => $test->{fields}, },
'submit update' );