Test Nominatim.describe_location
This commit is contained in:
parent
aad7dc3d24
commit
382e773793
1 changed files with 31 additions and 0 deletions
31
test/lib/nominatim_test.rb
Normal file
31
test/lib/nominatim_test.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require "test_helper"
|
||||
|
||||
class NominatimTest < ActiveSupport::TestCase
|
||||
def test_describe_location
|
||||
stub_request(:get, %r{^https://nominatim\.example\.com/reverse\?})
|
||||
.to_return(:body => "<reversegeocode><result>Target location</result></reversegeocode>")
|
||||
|
||||
with_settings(:nominatim_url => "https://nominatim.example.com/",
|
||||
:server_url => "osm-website.example.com") do
|
||||
location = Nominatim.describe_location(60, 30, 10, "en")
|
||||
assert_equal "Target location", location
|
||||
end
|
||||
|
||||
assert_requested :get, "https://nominatim.example.com/reverse?lat=60&lon=30&zoom=10&accept-language=en",
|
||||
:headers => { "User-Agent" => "osm-website.example.com" }
|
||||
end
|
||||
|
||||
def test_describe_location_no_result
|
||||
stub_request(:get, %r{^https://nominatim\.example\.com/reverse\?})
|
||||
.to_return(:body => "<reversegeocode><error>Unable to geocode</error></reversegeocode>")
|
||||
|
||||
with_settings(:nominatim_url => "https://nominatim.example.com/",
|
||||
:server_url => "osm-website.example.com") do
|
||||
location = Nominatim.describe_location(1, 2, 14, "en")
|
||||
assert_equal "1.000, 2.000", location
|
||||
end
|
||||
|
||||
assert_requested :get, "https://nominatim.example.com/reverse?lat=1&lon=2&zoom=14&accept-language=en",
|
||||
:headers => { "User-Agent" => "osm-website.example.com" }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue