diff options
author | Struan Donald <struan@exo.org.uk> | 2012-08-30 18:42:48 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-08-30 18:42:48 +0100 |
commit | 8e1336875a074adb7f906651233931e0ea4c22b7 (patch) | |
tree | 427bb3c33bb5aa5f10cbb776c66a28b3f8195ea7 /t/open311.t | |
parent | 7a5fed80a9b945b6cee6b034f26518d19751e61a (diff) |
If we don't get a request_id or it's not a text element then regard
posting the service request as having failed
Diffstat (limited to 't/open311.t')
-rw-r--r-- | t/open311.t | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/t/open311.t b/t/open311.t index f082179ea..835d8d8cb 100644 --- a/t/open311.t +++ b/t/open311.t @@ -410,20 +410,48 @@ for my $test ( }; } +subtest 'No request id in reponse' => sub { + my $results; + warning_like { + $results = make_service_req( + $problem, + { url => 'http://example.com/report/1' }, + $problem->category, + '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id></service_request_id></request></service_requests>' + ); + } qr/Failed to submit problem \d+ over Open311/, 'correct error message for missing request_id'; + + is $results->{ res }, 0, 'No request_id is a failure'; +}; + +subtest 'Bad data in request_id element in reponse' => sub { + my $results; + warning_like { + $results = make_service_req( + $problem, + { url => 'http://example.com/report/1' }, + $problem->category, + '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id><bad_data>BAD</bad_data></service_request_id></request></service_requests>' + ); + } qr/Failed to submit problem \d+ over Open311/, 'correct error message for bad data in request_id'; + + is $results->{ res }, 0, 'No request_id is a failure'; +}; + subtest 'No update id in reponse' => sub { my $results; warning_like { $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id></update_id></request_update></service_request_updates>' ) - } qr/Failed to submit comment \d+ over Open311/, 'correct error message'; + } qr/Failed to submit comment \d+ over Open311/, 'correct error message for missing update_id'; is $results->{ res }, 0, 'No update_id is a failure'; }; -subtest 'error reponse' => sub { +subtest 'error response' => sub { my $results; warning_like { $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><errors><error><code>400</code><description>There was an error</description</error></errors>' ) - } qr/Failed to submit comment \d+ over Open311.*There was an error/, 'correct error messages'; + } qr/Failed to submit comment \d+ over Open311.*There was an error/, 'correct error messages for general error'; is $results->{ res }, 0, 'error in response is a failure'; }; |