diff options
Diffstat (limited to 't/open311')
-rw-r--r-- | t/open311/getservicerequestupdates.t | 54 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 27 | ||||
-rw-r--r-- | t/open311/post-service-request-updates.t | 4 |
3 files changed, 82 insertions, 3 deletions
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 54a7f192d..055c5ea5f 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -1037,6 +1037,60 @@ foreach my $test ( { } } +subtest 'check matching on fixmystreet_id overrides service_request_id' => 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>8888888888888</service_request_id> + <fixmystreet_id>@{[ $problem->id ]}</fixmystreet_id> + <status>open</status> + <description>This is a note</description> + <updated_datetime>UPDATED_DATETIME</updated_datetime> + </request_update> + <request_update> + <update_id>638354</update_id> + <service_request_id>@{[ $problem->external_id ]}</service_request_id> + <fixmystreet_id>999999999</fixmystreet_id> + <status>open</status> + <description>This is a different note</description> + <updated_datetime>UPDATED_DATETIME2</updated_datetime> + </request_update> + <request_update> + <update_id>638356</update_id> + <service_request_id></service_request_id> + <fixmystreet_id>@{[ $problem->id ]}</fixmystreet_id> + <status>investigating</status> + <description>This is a last note</description> + <updated_datetime>UPDATED_DATETIME3</updated_datetime> + </request_update> + </service_requests_updates> + }; + + $problem->comments->delete; + + my $dt2 = $dt->clone->subtract( minutes => 30 ); + my $dt3 = $dt2->clone->subtract( minutes => 30 ); + $requests_xml =~ s/UPDATED_DATETIME3/$dt/; + $requests_xml =~ s/UPDATED_DATETIME2/$dt2/; + $requests_xml =~ s/UPDATED_DATETIME/$dt3/; + + 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( + system_user => $user, + ); + + $update->update_comments( $o, $bodies{2482} ); + + $problem->discard_changes; + is $problem->comments->count, 2, 'two comments after fetching updates'; + + my @comments = $problem->comments->search(undef, { order_by => [ 'created' ] } )->all; + + is $comments[0]->external_id, 638344, "correct first comment added"; + is $comments[1]->external_id, 638356, "correct second comment added"; +}; done_testing(); sub setup_xml { diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index 4d70dfebc..ff4c4cf9d 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -584,6 +584,15 @@ subtest 'check Bromley skip code' => sub { <order>1</order> <description>Type of bin</description> </attribute> + <attribute> + <variable>true</variable> + <code>easting</code> + <datatype>string</datatype> + <required>true</required> + <datatype_description>String</datatype_description> + <order>1</order> + <description>Easting</description> + </attribute> </attributes> </service_definition> '; @@ -626,6 +635,15 @@ subtest 'check Bromley skip code' => sub { order => 1, description => 'Type of bin' }, { + automated => 'server_set', + variable => 'true', + code => 'easting', + datatype => 'string', + required => 'true', + datatype_description => 'String', + order => 1, + description => 'Easting', + }, { automated => 'hidden_field', variable => 'true', code => 'prow_reference', @@ -671,7 +689,14 @@ subtest 'check Bromley skip code' => sub { datatype_description => 'Type of bin', order => 1, description => 'Type of bin' - + }, { + variable => 'true', + code => 'easting', + datatype => 'string', + required => 'true', + datatype_description => 'String', + order => 1, + description => 'Easting', }, ]; diff --git a/t/open311/post-service-request-updates.t b/t/open311/post-service-request-updates.t index 000bf3a2b..57b8f9a2a 100644 --- a/t/open311/post-service-request-updates.t +++ b/t/open311/post-service-request-updates.t @@ -15,8 +15,8 @@ my $params = { endpoint => 'endpoint', jurisdiction => 'home', }; -my $bromley = $mech->create_body_ok(2482, 'Bromley', { %$params, send_extended_statuses => 1 }); -my $oxon = $mech->create_body_ok(2237, 'Oxfordshire', $params); +my $bromley = $mech->create_body_ok(2482, 'Bromley', { %$params, send_extended_statuses => 1, id => 5 }); +my $oxon = $mech->create_body_ok(2237, 'Oxfordshire', { %$params, id => 55 }); my $bucks = $mech->create_body_ok(2217, 'Buckinghamshire', $params); my $lewisham = $mech->create_body_ok(2492, 'Lewisham', $params); |