aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2020-06-18 16:29:56 +0100
committerStruan Donald <struan@exo.org.uk>2020-09-09 13:53:57 +0100
commitf98bb79a77866fb08ec95f5e64f07faa0ba42ceb (patch)
tree073d4b4101efc5578541a609dba039afceab4f5d
parent43f92bcb01f04fe48eb87ff3a42afbf58540c690 (diff)
[Peterborough] add extra open311 properties for bartec
Bartec uses these to look up the UPRN of the property.
-rw-r--r--perllib/FixMyStreet/Cobrand/Peterborough.pm9
-rw-r--r--t/cobrand/peterborough.t61
2 files changed, 69 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Peterborough.pm b/perllib/FixMyStreet/Cobrand/Peterborough.pm
index dd6592a7c..199fcdd36 100644
--- a/perllib/FixMyStreet/Cobrand/Peterborough.pm
+++ b/perllib/FixMyStreet/Cobrand/Peterborough.pm
@@ -51,6 +51,15 @@ around open311_extra_data_include => sub {
$_->{value} .= "\n\nSkanska CSC ref: $ref->{value}" if $ref;
}
}
+ if ( $row->geocode && $row->contact->email =~ /Bartec/ ) {
+ my $address = $row->geocode->{resourceSets}->[0]->{resources}->[0]->{address};
+ my ($number, $street) = $address->{addressLine} =~ /\s*(\d*)\s*(.*)/;
+ push @$open311_only, (
+ { name => 'postcode', value => $address->{postalCode} },
+ { name => 'house_no', value => $number },
+ { name => 'street', value => $street }
+ );
+ }
return $open311_only;
};
# remove categories which are informational only
diff --git a/t/cobrand/peterborough.t b/t/cobrand/peterborough.t
index 5d07acb9f..5b461d4f2 100644
--- a/t/cobrand/peterborough.t
+++ b/t/cobrand/peterborough.t
@@ -64,7 +64,7 @@ subtest "extra update params are sent to open311" => sub {
test_get_returns => { 'servicerequestupdates.xml' => $test_res },
);
- my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', { external_id => 1, category => 'Trees' });
+ my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', { external_id => 1, category => 'Trees', whensent => DateTime->now });
my $c = FixMyStreet::DB->resultset('Comment')->create({
problem => $p, user => $p->user, anonymous => 't', text => 'Update text',
@@ -81,4 +81,63 @@ subtest "extra update params are sent to open311" => sub {
};
};
+subtest "bartec report with no gecode handled correctly" => sub {
+ FixMyStreet::override_config {
+ STAGING_FLAGS => { send_reports => 1 },
+ MAPIT_URL => 'http://mapit.uk/',
+ ALLOWED_COBRANDS => 'peterborough',
+ }, sub {
+ my $contact = $mech->create_contact_ok(body_id => $peterborough->id, category => 'Bins', email => 'Bartec-Bins');
+ my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', { category => 'Bins', latitude => 52.5608, longitude => 0.2405, cobrand => 'peterborough' });
+
+ my $test_data = FixMyStreet::Script::Reports::send();
+
+ $p->discard_changes;
+ ok $p->whensent, 'Report marked as sent';
+
+ my $req = $test_data->{test_req_used};
+ my $cgi = CGI::Simple->new($req->content);
+ is $cgi->param('attribute[postcode]'), undef, 'postcode param not set';
+ is $cgi->param('attribute[house_no]'), undef, 'house_no param not set';
+ is $cgi->param('attribute[street]'), undef, 'street param not set';
+ };
+};
+
+subtest "extra bartec params are sent to open311" => sub {
+ FixMyStreet::override_config {
+ STAGING_FLAGS => { send_reports => 1 },
+ MAPIT_URL => 'http://mapit.uk/',
+ ALLOWED_COBRANDS => 'peterborough',
+ }, sub {
+ my ($p) = $mech->create_problems_for_body(1, $peterborough->id, 'Title', {
+ category => 'Bins',
+ latitude => 52.5608,
+ longitude => 0.2405,
+ cobrand => 'peterborough',
+ geocode => {
+ resourceSets => [ {
+ resources => [ {
+ address => {
+ addressLine => '12 A Street',
+ postalCode => 'XX1 1XZ'
+ }
+ } ]
+ } ]
+ }
+ } );
+
+ my $test_data = FixMyStreet::Script::Reports::send();
+
+ $p->discard_changes;
+ ok $p->whensent, 'Report marked as sent';
+
+ my $req = $test_data->{test_req_used};
+ my $cgi = CGI::Simple->new($req->content);
+ is $cgi->param('attribute[postcode]'), 'XX1 1XZ', 'postcode param sent';
+ is $cgi->param('attribute[house_no]'), '12', 'house_no param sent';
+ is $cgi->param('attribute[street]'), 'A Street', 'street param sent';
+ };
+};
+
+
done_testing;