Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bristol] No service_code on passthrough updates. #397

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ around BUILDARGS => sub {
return $class->$orig(%args);
};

around post_service_request_update => sub {
my ($orig, $self, $args) = @_;
# Bristol's endpoint gets confused if it receives a service_code on an update
delete $args->{service_code};
return $self->$orig($args);
};

1;
52 changes: 52 additions & 0 deletions t/open311/endpoint/bristol_passthrough.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use strict;
use warnings;

BEGIN { $ENV{TEST_MODE} = 1; }

use Test::More;
use Test::MockModule;
use JSON::MaybeXS;
use Path::Tiny;

my $pt = Test::MockModule->new('Open311::Endpoint::Integration::UK::Bristol::Passthrough');
$pt->mock(endpoint => sub { '' });

my $expected_update_post = <<XML;
<?xml version="1.0" encoding="utf-8"?>
<service_request_updates>
<request_update>
<update_id>2002</update_id>
</request_update>
</service_request_updates>
XML

my $ua = Test::MockModule->new('LWP::UserAgent');
$ua->mock(post => sub {
my $args = $_[2];
is $args->{service_code}, undef;
return HTTP::Response->new(200, 'OK', [], $expected_update_post);
});

use_ok 'Open311::Endpoint::Integration::UK::Bristol::Passthrough';

my $endpoint = Open311::Endpoint::Integration::UK::Bristol::Passthrough->new;

subtest 'POST update' => sub {
my $res = $endpoint->run_test_request(
POST => '/servicerequestupdates.xml',
api_key => 'test',
service_code => 'SE01',
service_request_id => 1001,
update_id => 123,
# first_name => 'Bob',
# last_name => 'Mould',
description => 'Update here',
status => 'OPEN',
updated_datetime => '2016-09-01T15:00:00Z',
# media_url => 'http://example.org/',
);
ok $res->is_success, 'valid request' or diag $res->content;
is $res->content, $expected_update_post;
};

done_testing;