aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-04-05 16:37:32 +0100
committerStruan Donald <struan@exo.org.uk>2018-04-11 10:42:52 +0100
commit80754df967ceee0180679ffcdde55d22aad4ac21 (patch)
treed40c848a59ee932f77714dffbb12ac44b846092f /t
parent1d25da206d2e1ed2d2f841d65461e4a9449dd751 (diff)
[Open311] fetch_all option for open311 problem fetching
If a body has a `fetch_all_reports` setting in the extra metadata then all reports are fetched over Open311 and processed regardless of age. This is useful for bodies where the API endpoint always returns all the reports as it suppresses the error messages you would otherwise get about reports with invalid dates.
Diffstat (limited to 't')
-rw-r--r--t/open311/getservicerequests.t41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/open311/getservicerequests.t b/t/open311/getservicerequests.t
index c59e5cc41..57f112e2f 100644
--- a/t/open311/getservicerequests.t
+++ b/t/open311/getservicerequests.t
@@ -273,6 +273,47 @@ for my $test (
};
}
+subtest 'check fetch_all body setting ignores date errors' => sub {
+ my $xml = prepare_xml({ id => '12345678' });
+
+ $body->update( {
+ send_method => 'Open311',
+ fetch_problems => 1,
+ comment_user_id => $user->id,
+ endpoint => 'http://open311.localhost/',
+ api_key => 'KEY',
+ jurisdiction => 'test',
+ } );
+ $body->set_extra_metadata( fetch_all_problems => 1 );
+ $body->update();
+
+ my $update = Open311::GetServiceRequests->new(
+ verbose => 1,
+ system_user => $user,
+ );
+ $update = Test::MockObject::Extends->new($update);
+
+ $update->mock('create_open311_object', sub {
+ return Open311->new(
+ jurisdiction => 'mysociety',
+ endpoint => 'http://example.com',
+ test_mode => 1,
+ test_get_returns => { 'requests.xml' => $xml}
+ );
+ } );
+
+ my $count = FixMyStreet::DB->resultset('Problem')->count;
+ FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $update->fetch;
+ };
+
+ my $after = FixMyStreet::DB->resultset('Problem')->count;
+
+ is $after, $count + 1, 'problem created';
+};
+
for my $test (
{
desc => 'convert easting/northing to lat/long',