diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-05-18 20:12:16 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-05-18 20:12:16 +0100 |
commit | 675744156c56d7b5ea5c8866fdd59a1c3cbcee1b (patch) | |
tree | 9ac7bb95f77ed5c473f9dd2a62be70959a4508b0 /t/Mock/Bing.pm | |
parent | 61eb613ddc31943e9d6504050c0e96f91340f752 (diff) |
[UK] Stop nearest request with scientific notation
If the longitude was very close to 0, it was being sent as e.g. 1e-6
in the request to MapIt. Mock out the Bing query so that this can be
tested (the closest.t tests were previously always being skipped).
Diffstat (limited to 't/Mock/Bing.pm')
-rw-r--r-- | t/Mock/Bing.pm | 37 |
1 files changed, 37 insertions, 0 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; |