diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-03-15 13:29:42 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-03-23 08:56:06 +0000 |
commit | cb49284dc0503b2a05ca2bb98b8a1320431c2616 (patch) | |
tree | be4ddb1fc16cf45b67e3cf0683506a493de4b27e /t/open311 | |
parent | d3d0ab6d5a753d1e5c8277db981f03823683ae1f (diff) |
Updates to cpanfile and code for perl 5.20/5.22.
The following modules had bugs that have been fixed for working in
recent perls:
* List::MoreUtils
* Guard
* PadWalker
* aliased
* URI
* Convert::NLS_DATE_FORMAT
The CGI module was removed from core in 5.20, so include it in the
snapshot (I don't think it's actually used, but is a dependency).
"{" needs to be escaped in regular expressions, and ~~ should not be
used.
Fix some tests that expect e.g. a certain hash ordering, to use sorted
output or better comparisons.
Diffstat (limited to 't/open311')
-rw-r--r-- | t/open311/endpoint.t | 18 | ||||
-rw-r--r-- | t/open311/endpoint/Endpoint1.pm | 3 | ||||
-rw-r--r-- | t/open311/getupdates.t | 22 |
3 files changed, 26 insertions, 17 deletions
diff --git a/t/open311/endpoint.t b/t/open311/endpoint.t index 38314f079..a2a4ea83e 100644 --- a/t/open311/endpoint.t +++ b/t/open311/endpoint.t @@ -89,10 +89,6 @@ subtest "GET Service Definition" => sub { <required>false</required> <values> <value> - <name>Triangle</name> - <key>triangle</key> - </value> - <value> <name>Circle</name> <key>circle</key> </value> @@ -100,6 +96,10 @@ subtest "GET Service Definition" => sub { <name>Square</name> <key>square</key> </value> + <value> + <name>Triangle</name> + <key>triangle</key> + </value> </values> <variable>true</variable> </attribute> @@ -133,17 +133,17 @@ CONTENT "datatype" => "singlevaluelist", "values" => [ { - "name" => "Triangle", - "key" => "triangle" - }, - { "name" => "Circle", "key" => "circle" }, { "name" => "Square", "key" => "square" - } + }, + { + "name" => "Triangle", + "key" => "triangle" + }, ], } ], diff --git a/t/open311/endpoint/Endpoint1.pm b/t/open311/endpoint/Endpoint1.pm index c4119075c..ae12172b8 100644 --- a/t/open311/endpoint/Endpoint1.pm +++ b/t/open311/endpoint/Endpoint1.pm @@ -103,8 +103,7 @@ sub get_service_requests { my ($self, $args) = @_; my $service_code = $args->{service_code} or return $self->get_requests; - # we use ~~ as the service_code arg will be an arrayref like ['POT'] - return $self->filter_requests( sub { shift->service->service_code ~~ $service_code }); + return $self->filter_requests( sub { my $c = shift->service->service_code; grep { $_ eq $c } @$service_code }); } sub get_service_request { diff --git a/t/open311/getupdates.t b/t/open311/getupdates.t index fef51e0e1..0e31db482 100644 --- a/t/open311/getupdates.t +++ b/t/open311/getupdates.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More; +use URI::Split qw(uri_split); use FixMyStreet; use FixMyStreet::DB; @@ -103,8 +104,11 @@ for my $test ( my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'requests.xml' => $local_requests_xml } ); - ok $updates->update_reports( [ 638344 ], $o, $body ); - is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638344', 'get url'; + ok $updates->update_reports( [ 638344 ], $o, $body ), 'Updated reports'; + my @parts = uri_split($o->test_uri_used); + is $parts[2], '/requests.xml', 'path matches'; + my @qs = sort split '&', $parts[3]; + is_deeply(\@qs, [ 'jurisdiction_id=mysociety', 'service_request_id=638344' ], 'query string matches'); is $problem->comments->count, $test->{comment_count}, 'added a comment'; }; @@ -178,8 +182,11 @@ subtest 'update with two requests' => sub { my $o = Open311->new( jurisdiction => 'mysociety', endpoint => 'http://example.com', test_mode => 1, test_get_returns => { 'requests.xml' => $local_requests_xml } ); - ok $updates->update_reports( [ 638344,638345 ], $o, $body ); - is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638344%2C638345', 'get url'; + ok $updates->update_reports( [ 638344,638345 ], $o, $body ), 'Updated reports'; + my @parts = uri_split($o->test_uri_used); + is $parts[2], '/requests.xml', 'path matches'; + my @qs = sort split '&', $parts[3]; + is_deeply(\@qs, [ 'jurisdiction_id=mysociety', 'service_request_id=638344%2C638345' ], 'query string matches'); is $problem->comments->count, 1, 'added a comment to first problem'; is $problem2->comments->count, 1, 'added a comment to second problem'; @@ -232,9 +239,12 @@ subtest 'test translation of auto-added comment from old-style Open311 update' = FixMyStreet::override_config { ALLOWED_COBRANDS => [ 'fixamingata' ], }, sub { - ok $updates->update_reports( [ 638346 ], $o, $body ); + ok $updates->update_reports( [ 638346 ], $o, $body ), 'Updated reports'; }; - is $o->test_uri_used, 'http://example.com/requests.xml?jurisdiction_id=mysociety&service_request_id=638346', 'get url'; + my @parts = uri_split($o->test_uri_used); + is $parts[2], '/requests.xml', 'path matches'; + my @qs = sort split '&', $parts[3]; + is_deeply(\@qs, [ 'jurisdiction_id=mysociety', 'service_request_id=638346' ], 'query string matches'); is $problem3->comments->count, 1, 'added a comment'; is $problem3->comments->first->text, "St\xe4ngd av kommunen", 'correct comment text'; |