diff options
author | Matthew Somerville <matthew@mysociety.org> | 2016-01-29 15:12:29 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-01-29 15:12:29 +0000 |
commit | 68dda6c87e0ea01e9934b18f1061c0066f352e9e (patch) | |
tree | 2de1c83495b7e905beb75d225a8d4044c0a718e2 /t/Mock/Nominatim.pm | |
parent | 32cc764609a304fb09718e91ca836c8788db1f51 (diff) | |
parent | b4e69645bd2ff24fb603bf7461e2c80b316eaeaa (diff) |
Merge branch '1315-open311-update-media_url'
Diffstat (limited to 't/Mock/Nominatim.pm')
-rw-r--r-- | t/Mock/Nominatim.pm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/t/Mock/Nominatim.pm b/t/Mock/Nominatim.pm new file mode 100644 index 000000000..3f3cef69a --- /dev/null +++ b/t/Mock/Nominatim.pm @@ -0,0 +1,37 @@ +package t::Mock::Nominatim; + +use JSON; +use Web::Simple; + +has json => ( + is => 'lazy', + default => sub { + JSON->new->pretty->allow_blessed->convert_blessed; + }, +); + +sub dispatch_request { + my $self = shift; + + sub (GET + /search + ?q=) { + my ($self, $q) = @_; + my $response = $self->query($q); + my $json = $self->json->encode($response); + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + }, +} + +sub query { + my ($self, $q) = @_; + if ($q eq 'high street') { + return [ + {"osm_type"=>"way","osm_id"=>"4684282","lat"=>"55.9504009","lon"=>"-3.1858425","display_name"=>"High Street, Old Town, City of Edinburgh, Scotland, EH1 1SP, United Kingdom","class"=>"highway","type"=>"tertiary","importance"=>0.55892577838734}, + {"osm_type"=>"node","osm_id"=>"27424410","lat"=>"55.8596449","lon"=>"-4.240377","display_name"=>"High Street, Collegelands, Merchant City, Glasgow, Glasgow City, Scotland, G, United Kingdom","class"=>"railway","type"=>"station","importance"=>0.53074299592768} + ]; + } + return []; +} + + + +__PACKAGE__->run_if_script; |