From 14052e711b2ba08970983a69058c590d112df16e Mon Sep 17 00:00:00 2001 From: Moray Jones Date: Fri, 2 Aug 2024 16:10:32 +0100 Subject: [PATCH] [Camden] Add nearest_address to location field Request for location field to contain nearest_address data https://3.basecamp.com/4020879/buckets/36530864/todos/7607947511#__recording_7668470194 --- .../Integration/UK/Camden/ConfirmTrees.pm | 9 ++ t/open311/endpoint/camden_confirm.t | 89 +++++++++++++++++++ .../endpoint/{camden.t => camden_symology.t} | 65 -------------- 3 files changed, 98 insertions(+), 65 deletions(-) create mode 100644 t/open311/endpoint/camden_confirm.t rename t/open311/endpoint/{camden.t => camden_symology.t} (84%) diff --git a/perllib/Open311/Endpoint/Integration/UK/Camden/ConfirmTrees.pm b/perllib/Open311/Endpoint/Integration/UK/Camden/ConfirmTrees.pm index 3a03d5471..dbb07724e 100644 --- a/perllib/Open311/Endpoint/Integration/UK/Camden/ConfirmTrees.pm +++ b/perllib/Open311/Endpoint/Integration/UK/Camden/ConfirmTrees.pm @@ -16,4 +16,13 @@ around BUILDARGS => sub { return $class->$orig(%args); }; +sub process_service_request_args { + my $self = shift; + my $args = $self->SUPER::process_service_request_args(shift); + + $args->{location} = $args->{location} . '; ' . $args->{attributes}->{closest_address}; + + return $args; +} + 1; diff --git a/t/open311/endpoint/camden_confirm.t b/t/open311/endpoint/camden_confirm.t new file mode 100644 index 000000000..5b76533ed --- /dev/null +++ b/t/open311/endpoint/camden_confirm.t @@ -0,0 +1,89 @@ +use strict; +use warnings; + +BEGIN { $ENV{TEST_MODE} = 1; } + +use Test::More; +use Test::MockModule; +use Path::Tiny; + +my $confirm_integ = Test::MockModule->new('Integrations::Confirm'); +$confirm_integ->mock(config => sub { + { + endpoint_url => 'http://www.example.org/', + } +}); + +$confirm_integ->mock(perform_request => sub { + my ($self, $op) = @_; # Don't care about subsequent ops + $op = $$op; + if ($op->name && $op->name eq 'GetEnquiryLookups') { + return { + OperationResponse => { GetEnquiryLookupsResponse => { TypeOfService => [ + { ServiceCode => 'ABC', ServiceName => 'Trees', EnquirySubject => [ { SubjectCode => "DEF" } ] }, + ] } } + }; + } + return {}; +}); + +use_ok 'Open311::Endpoint::Integration::UK::Camden::ConfirmTrees'; + +my $endpoint = Open311::Endpoint::Integration::UK::Camden::ConfirmTrees->new( + config_file => path(__FILE__)->sibling("camden_confirm_trees.yml")->stringify, +); + +subtest "GET Service List" => sub { + +my $res = $endpoint->run_test_request( GET => '/services.xml' ); + ok $res->is_success, 'xml success'; + my $expected = < + + + Blocking streetlight + + Trees + + + true + ABC_DEF + Blocking streetlight + realtime + + + Blocking traffic signal/sign + + Trees + + + true + ABC_DEF_1 + Blocking traffic signal/sign + realtime + + +XML + my $content = $res->content; + $content =~ s/\s+//g; + $expected =~ s/\s+//g; + is $content, $expected + or diag $res->content; +}; + +subtest process_service_request_args => sub { + my $args = { + attributes => { + description => 'Tree overhanging garden fence and blocking light', + fixmystreet_id => '2157', + location => 'Opposite post office', + report_url => 'http://camden.example.org/report/2157', + closest_address => '1 High Street, Town Centre', + }, + service_code => 'ABC_DEF', + }; + + is $endpoint->process_service_request_args($args)->{location}, 'Opposite post office; 1 High Street, Town Centre', 'Nearest address combined into location field'; +}; + +done_testing; diff --git a/t/open311/endpoint/camden.t b/t/open311/endpoint/camden_symology.t similarity index 84% rename from t/open311/endpoint/camden.t rename to t/open311/endpoint/camden_symology.t index 24c902272..f6f69b0bd 100644 --- a/t/open311/endpoint/camden.t +++ b/t/open311/endpoint/camden_symology.t @@ -291,69 +291,4 @@ subtest "GET updates OK" => sub { ok 1; }; - -my $confirm_integ = Test::MockModule->new('Integrations::Confirm'); -$confirm_integ->mock(config => sub { - { - endpoint_url => 'http://www.example.org/', - } -}); - -$confirm_integ->mock(perform_request => sub { - my ($self, $op) = @_; # Don't care about subsequent ops - $op = $$op; - if ($op->name && $op->name eq 'GetEnquiryLookups') { - return { - OperationResponse => { GetEnquiryLookupsResponse => { TypeOfService => [ - { ServiceCode => 'ABC', ServiceName => 'Trees', EnquirySubject => [ { SubjectCode => "DEF" } ] }, - ] } } - }; - } - return {}; -}); - -use_ok 'Open311::Endpoint::Integration::UK::Camden::ConfirmTrees'; - -$endpoint = Open311::Endpoint::Integration::UK::Camden::ConfirmTrees->new( - config_file => path(__FILE__)->sibling("camden_confirm_trees.yml")->stringify, -); - -subtest "GET Service List" => sub { - -my $res = $endpoint->run_test_request( GET => '/services.xml' ); - ok $res->is_success, 'xml success'; - my $expected = < - - - Blocking streetlight - - Trees - - - true - ABC_DEF - Blocking streetlight - realtime - - - Blocking traffic signal/sign - - Trees - - - true - ABC_DEF_1 - Blocking traffic signal/sign - realtime - - -XML - my $content = $res->content; - $content =~ s/\s+//g; - $expected =~ s/\s+//g; - is $content, $expected - or diag $res->content; -}; - done_testing;