aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm7
-rw-r--r--perllib/Integrations/Echo.pm66
-rw-r--r--t/app/controller/waste.t5
-rw-r--r--t/cobrand/bromley.t10
4 files changed, 52 insertions, 36 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index e84ea6f30..d91570f83 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -523,7 +523,7 @@ sub bin_services_for_address {
my $result = $echo->GetServiceUnitsForObject($property->{uprn});
return [] unless @$result;
- my $events = $echo->GetEventsForObject($property->{id});
+ my $events = $echo->GetEventsForObject('PointAddress', $property->{id});
my $open = $self->_parse_open_events($events);
my @out;
@@ -536,13 +536,16 @@ sub bin_services_for_address {
next unless $schedules->{next} or $schedules->{last};
+ my $events = $echo->GetEventsForObject('ServiceUnit', $_->{Id});
+ my $open_unit = $self->_parse_open_events($events);
+
my $containers = $service_to_containers{$_->{ServiceId}};
my ($open_request) = grep { $_ } map { $open->{request}->{$_} } @$containers;
my $row = {
id => $_->{Id},
service_id => $_->{ServiceId},
service_name => $service_name_override{$_->{ServiceId}} || $_->{ServiceName},
- report_open => $open->{missed}->{$_->{ServiceId}},
+ report_open => $open->{missed}->{$_->{ServiceId}} || $open_unit->{missed}->{$_->{ServiceId}},
request_allowed => $request_allowed{$_->{ServiceId}},
request_open => $open_request,
request_containers => $containers,
diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm
index c9eab0cfc..ec21da8fa 100644
--- a/perllib/Integrations/Echo.pm
+++ b/perllib/Integrations/Echo.pm
@@ -90,13 +90,16 @@ sub GetTasks {
}
return [
- { Ref => { Value => { anyType => [ 123, 456 ] } }, CompletedDate => undef },
{
- Ref => { Value => { anyType => [ 234, 567 ] } },
+ Ref => { Value => { anyType => [ 123, 456 ] } },
State => { Name => 'Completed' },
Resolution => { Name => 'Wrong Bin Out' },
CompletedDate => { DateTime => '2020-05-27T10:00:00Z' }
},
+ {
+ Ref => { Value => { anyType => [ 234, 567 ] } },
+ CompletedDate => undef
+ },
{ Ref => { Value => { anyType => [ 345, 678 ] } }, CompletedDate => undef },
{ Ref => { Value => { anyType => [ 456, 789 ] } }, CompletedDate => undef },
] if $self->sample_data;
@@ -319,41 +322,50 @@ sub GetEventType {
}
sub GetEventsForObject {
- my ($self, $id, $type) = @_;
+ my ($self, $type, $id, $event_type) = @_;
my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone)->subtract(months => 3);
- return [ {
- # Missed collection for service 542 (food waste)
- EventTypeId => 2100,
- ServiceId => 542,
- }, { # And a gate not closed
- EventTypeId => 2118,
- ServiceId => 542,
- }, {
- # Request for a new paper container
- EventTypeId => 2104,
- Data => { ExtensibleDatum => [
- { Value => 2, DatatypeName => 'Source' },
- {
- ChildData => { ExtensibleDatum => [
- { Value => 1, DatatypeName => 'Action' },
- { Value => 12, DatatypeName => 'Container Type' },
- ] },
- },
- ] },
- ServiceId => 535,
- } ] if $self->sample_data;
+ if ($self->sample_data) {
+ return [ {
+ # Missed collection for service 542 (food waste)
+ EventTypeId => 2100,
+ ServiceId => 542,
+ }, { # And a gate not closed
+ EventTypeId => 2118,
+ ServiceId => 542,
+ }, {
+ # Request for a new paper container
+ EventTypeId => 2104,
+ Data => { ExtensibleDatum => [
+ { Value => 2, DatatypeName => 'Source' },
+ {
+ ChildData => { ExtensibleDatum => [
+ { Value => 1, DatatypeName => 'Action' },
+ { Value => 12, DatatypeName => 'Container Type' },
+ ] },
+ },
+ ] },
+ ServiceId => 535,
+ } ] if $type eq 'PointAddress';
+ return [ {
+ # Missed collection for service 537 (paper)
+ EventTypeId => 2099,
+ ServiceId => 537,
+ } ] if $type eq 'ServiceUnit' && $id == 1002;
+ return [];
+ }
+
# uncoverable statement
my $res = $self->call('GetEventsForObject',
objectRef => ixhash(
Key => 'Id',
- Type => 'PointAddress',
+ Type => $type,
Value => { 'msArray:anyType' => $id },
),
query => ixhash(
- $type ? (EventTypeRef => ixhash(
+ $event_type ? (EventTypeRef => ixhash(
Key => 'Id',
Type => 'EventType',
- Value => { 'msArray:anyType' => $type },
+ Value => { 'msArray:anyType' => $event_type },
)) : (),
From => dt_to_hash($from),
),
diff --git a/t/app/controller/waste.t b/t/app/controller/waste.t
index aac898da9..c86802631 100644
--- a/t/app/controller/waste.t
+++ b/t/app/controller/waste.t
@@ -61,15 +61,16 @@ FixMyStreet::override_config {
};
subtest 'Thing already requested' => sub {
$mech->content_contains('A food waste collection has been reported as missed');
+ $mech->content_contains('A paper & cardboard collection has been reported as missed'); # as part of service unit, not property
};
subtest 'Report a missed bin' => sub {
$mech->content_contains('service-101', 'Can report, last collection was 27th');
- $mech->content_contains('service-537', 'Can report, last collection was 27th');
+ $mech->content_lacks('service-537', 'Cannot report, last collection was 27th but the service unit has a report');
$mech->content_lacks('service-535', 'Cannot report, last collection was 20th');
$mech->content_lacks('service-542', 'Cannot report, last collection was 18th');
$mech->follow_link_ok({ text => 'Report a missed collection' });
$mech->content_contains('service-101', 'Checkbox, last collection was 27th');
- $mech->content_contains('service-537', 'Checkbox, last collection was 27th');
+ $mech->content_lacks('service-537', 'No checkbox, last collection was 27th but the service unit has a report');
$mech->content_lacks('service-535', 'No checkbox, last collection was 20th');
$mech->content_lacks('service-542', 'No checkbox, last collection was 18th');
$mech->submit_form_ok({ form_number => 2 });
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index a60f72b0d..c8683c017 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -290,17 +290,17 @@ subtest 'test reporting before/after completion' => sub {
$mech->get_ok('/waste/uprn/12345');
$mech->content_contains('(completed at 10:00am)');
$mech->content_contains('Wrong Bin Out');
- $mech->content_lacks('Report a refuse collection');
- $mech->content_contains('Report a paper & cardboard collection as missed');
+ $mech->content_lacks('Report a paper & cardboard collection');
+ $mech->content_contains('Report a refuse collection');
set_fixed_time('2020-05-28T12:00:00Z');
$mech->get_ok('/waste/uprn/12345');
- $mech->content_contains('Report a paper & cardboard collection as missed');
+ $mech->content_contains('Report a refuse collection');
set_fixed_time('2020-05-29T12:00:00Z');
$mech->get_ok('/waste/uprn/12345');
- $mech->content_contains('Report a paper & cardboard collection as missed');
+ $mech->content_contains('Report a refuse collection');
set_fixed_time('2020-05-30T12:00:00Z');
$mech->get_ok('/waste/uprn/12345');
- $mech->content_lacks('Report a paper & cardboard collection as missed');
+ $mech->content_lacks('Report a refuse collection');
};
restore_time();
};