diff options
Diffstat (limited to 't/Mock')
-rw-r--r-- | t/Mock/Bing.pm | 37 | ||||
-rw-r--r-- | t/Mock/MapIt.pm | 3 |
2 files changed, 39 insertions, 1 deletions
diff --git a/t/Mock/Bing.pm b/t/Mock/Bing.pm new file mode 100644 index 000000000..3dfb8fbe0 --- /dev/null +++ b/t/Mock/Bing.pm @@ -0,0 +1,37 @@ +package t::Mock::Bing; + +use JSON::MaybeXS; +use Web::Simple; +use LWP::Protocol::PSGI; + +has json => ( + is => 'lazy', + default => sub { + JSON->new->pretty->allow_blessed->convert_blessed; + }, +); + +sub dispatch_request { + my $self = shift; + + sub (GET + /REST/v1/Locations/* + ?*) { + my ($self, $location, $query) = @_; + my $data = { + resourceSets => [ { + resources => [ { + name => 'Constitution Hill, London, SW1A', + address => { + addressLine => 'Constitution Hill', + locality => 'London', + } + } ], + } ], + }; + my $json = $self->json->encode($data); + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + }, +} + +LWP::Protocol::PSGI->register(t::Mock::Bing->to_psgi_app, host => 'dev.virtualearth.net'); + +__PACKAGE__->run_if_script; diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm index 0b355983b..24e7a8084 100644 --- a/t/Mock/MapIt.pm +++ b/t/Mock/MapIt.pm @@ -32,6 +32,7 @@ my @PLACES = ( [ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ], [ 'WS1 4NH', 52.563074, -1.991032, 2535, 'Sandwell Borough Council', 'MTD' ], [ 'OX28 4DS', 51.784721, -1.494453 ], + [ 'E14 2DN', 51.508536, '0.000001' ], ); sub dispatch_request { @@ -112,7 +113,7 @@ sub dispatch_request { foreach (@PLACES) { if ($point eq "4326/$_->[2],$_->[1]") { return $self->output({ - postcode => { wgs84_lat => $_->[1], wgs84_lon => $_->[2], postcode => $_->[0] }, + postcode => { wgs84_lat => $_->[1], wgs84_lon => $_->[2], postcode => $_->[0], distance => 93 }, }); } } |