Skip to content

Commit

Permalink
[Camden] Adds test file
Browse files Browse the repository at this point in the history
Sets up test file and adds test for service white list
  • Loading branch information
MorayMySoc committed Oct 9, 2024
1 parent 6e6bfcc commit 4240c6f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
65 changes: 65 additions & 0 deletions t/open311/endpoint/camden.t
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,69 @@ 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 = <<XML;
<?xml version="1.0" encoding="utf-8"?>
<services>
<service>
<description>Blocking streetlight</description>
<groups>
<group>Trees</group>
</groups>
<keywords></keywords>
<metadata>true</metadata>
<service_code>ABC_DEF</service_code>
<service_name>Blocking streetlight</service_name>
<type>realtime</type>
</service>
<service>
<description>Blocking traffic signal/sign</description>
<groups>
<group>Trees</group>
</groups>
<keywords></keywords>
<metadata>true</metadata>
<service_code>ABC_DEF_1</service_code>
<service_name>Blocking traffic signal/sign</service_name>
<type>realtime</type>
</service>
</services>
XML
my $content = $res->content;
$content =~ s/\s+//g;
$expected =~ s/\s+//g;
is $content, $expected
or diag $res->content;
};

done_testing;
4 changes: 4 additions & 0 deletions t/open311/endpoint/camden_confirm_trees.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"service_whitelist":
"Trees":
"ABC_DEF": "Blocking streetlight"
"ABC_DEF_1": "Blocking traffic signal/sign"

0 comments on commit 4240c6f

Please sign in to comment.