Skip to content

Commit

Permalink
[Northumberland] Send updates to extra_details to Alloy
Browse files Browse the repository at this point in the history
  • Loading branch information
nephila-nacrea committed Sep 4, 2024
1 parent 93c66a8 commit ab27f46
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
18 changes: 14 additions & 4 deletions perllib/Open311/Endpoint/Integration/UK/NorthumberlandAlloy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,25 @@ sub process_attributes {
Adds an update for the status attribute given by C<update_status_attribute_id>, using the mapping C<update_status_mapping>.
Adds an update for 'extra_details' field ('FMS Extra Details' on Alloy end).
=cut

sub update_additional_attributes {
my ($self, $args) = @_;

return [{
attributeCode => $self->config->{update_status_attribute_id},
value => [ $self->config->{update_status_mapping}->{lc ($args->{status})} ]
}];
return [
{ attributeCode => $self->config->{update_status_attribute_id},
value => [
$self->config->{update_status_mapping}
->{ lc( $args->{status} ) }
],
},
{ attributeCode =>
$self->config->{inspection_attribute_mapping}{extra_details},
value => $args->{extra_details},
},
];
}

=head2 get_assigned_to_users
Expand Down
1 change: 1 addition & 0 deletions perllib/Open311/Endpoint/Role/mySociety.pm
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ sub POST_Service_Request_Update_input_schema {
public_anonymity_required => Open311::Endpoint::Schema->enum('//str', 'TRUE', 'FALSE'),
email_alerts_requested => Open311::Endpoint::Schema->enum('//str', 'TRUE', 'FALSE'),
service_code => $self->get_identifier_type('service_code'),
extra_details => '//str',
}
};

Expand Down
19 changes: 14 additions & 5 deletions t/open311/endpoint/northumberland_alloy.t
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,21 @@ subtest "check fetch updates" => sub {
], 'correct json returned';
};

subtest "update status on problem" => sub {
subtest "send updates for problem" => sub {
my $extra_details = <<HERE;
Red and
yellow and
pink
HERE

my $res = $endpoint->run_test_request(
POST => '/servicerequestupdates.json',
jurisdiction_id => 'dummy',
api_key => 'test',
service_code => 'Damaged_/_Missing_/_Facing_Wrong_Way',
description => 'update',
status => 'FIXED',
extra_details => $extra_details,
service_request_id => '642062376be3a0036bbbb64b',
update_id => '1',
updated_datetime => '2023-05-15T14:55:55+00:00',
Expand All @@ -457,15 +464,17 @@ subtest "update status on problem" => sub {
my $expected_status_attribute_code = 'attributes_customerRequestMainFMSStatus_63fcb297c9ec9c036ec35dfb';
my $expected_status_attribute_value = '63fcb00c753aed036a5e43a2';

my $status_match_found = 0;
my $expected_extra_details_attribute_code = 'attributes_customerRequestFMSExtraDetails_646e07533726d8036a7a4022';
my $expected_extra_details_attribute_value = $extra_details;

foreach (@{ $attributes }) {
if ($_->{attributeCode} eq $expected_status_attribute_code) {
ok ref($_->{value}) eq 'ARRAY' && $_->{value}[0] eq $expected_status_attribute_value, "value sent in status attribute update is correct";
$status_match_found = 1;
last;
}
if ($_->{attributeCode} eq $expected_extra_details_attribute_code) {
ok $_->{value} eq $expected_extra_details_attribute_value, "value sent in extra_details attribute update is correct";
}
}
ok $status_match_found, "status attribute update was sent";
};

done_testing;

0 comments on commit ab27f46

Please sign in to comment.