aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-10-30 16:24:41 +0000
committerStruan Donald <struan@exo.org.uk>2018-11-02 11:41:52 +0000
commit96c9b73552ceb6d35f879dc212ee0fcc1cdcd6da (patch)
treec05ede9d8c2b92743f489a44da43ee9fab1b3d90 /t/open311
parent321ad0d6742f6fa9cf53bfa4d88bf9cbabfc4b83 (diff)
allow comment fetching to be limited by body name
Allows creating scripts that fetch comments for a single body, e.g for batch updating or because they require special setup.
Diffstat (limited to 't/open311')
-rw-r--r--t/open311/getservicerequestupdates.t42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 7ebab3b3f..b9e29c99e 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -725,6 +725,48 @@ subtest 'check that existing comments are not duplicated' => sub {
is $problem->comments->count, 2, 'if comments are deleted then they are added';
};
+subtest 'check that can limit fetching to a body' => sub {
+ my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?>
+ <service_requests_updates>
+ <request_update>
+ <update_id>638344</update_id>
+ <service_request_id>@{[ $problem->external_id ]}</service_request_id>
+ <status>open</status>
+ <description>This is a note</description>
+ <updated_datetime>UPDATED_DATETIME</updated_datetime>
+ </request_update>
+ </service_requests_updates>
+ };
+
+ $problem->comments->delete;
+
+ is $problem->comments->count, 0, 'one comment before fetching updates';
+
+ $requests_xml =~ s/UPDATED_DATETIME/$dt/;
+
+ my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'servicerequestupdates.xml' => $requests_xml } );
+
+ my $update = Open311::GetServiceRequestUpdates->new(
+ body => 'Oxfordshire',
+ system_user => $user,
+ );
+
+ $update->fetch( $o );
+
+ $problem->discard_changes;
+ is $problem->comments->count, 0, 'no comments after fetching updates';
+
+ $update = Open311::GetServiceRequestUpdates->new(
+ body => 'Bromley',
+ system_user => $user,
+ );
+
+ $update->fetch( $o );
+
+ $problem->discard_changes;
+ is $problem->comments->count, 1, '1 comment after fetching updates';
+};
+
subtest 'check that external_status_code is stored correctly' => sub {
my $requests_xml = qq{<?xml version="1.0" encoding="utf-8"?>
<service_requests_updates>