From 8283a39dbc2b8c871db22ebc6cd9a13582c918fc Mon Sep 17 00:00:00 2001 From: Simon Poole Date: Thu, 25 Feb 2016 16:32:14 +0100 Subject: [PATCH] Support returning a HTTP status code for the http stubs for testing --- test/http/geocoder_ca.yml | 100 +++++---- test/http/geocoder_us.yml | 8 +- test/http/geonames.yml | 450 +++++++++++++++++++------------------- test/http/nominatim.yml | 98 +++++---- test/http/npemap.yml | 14 +- test/test_helper.rb | 4 +- 6 files changed, 351 insertions(+), 323 deletions(-) diff --git a/test/http/geocoder_ca.yml b/test/http/geocoder_ca.yml index 754885a5b..88a3fdc94 100644 --- a/test/http/geocoder_ca.yml +++ b/test/http/geocoder_ca.yml @@ -1,48 +1,54 @@ -/?geoit=XML&postal=A1B+2C3: | - - - 47.172520 - -55.440515 - A1B2C3 - - 1 - - ST. JOHN&'S - NL - 0.9 - - +/?geoit=XML&postal=A1B+2C3: + code: 200 + body: | + + + 47.172520 + -55.440515 + A1B2C3 + + 1 + + ST. JOHN&'S + NL + 0.9 + + -/?geoit=XML&postal=k1a+0b1: | - - - 45.375437 - -75.691041 - K1A0B1 - - 1 - - OTTAWA - ON - 0.9 - - - -/?geoit=XML&postal=Q0Q+0Q0: | - - - - 008 - Your request did not produce any results. Check your spelling and try again. - - - - - Q0Q0Q0 - - 1 - - - - 0.9 - - +/?geoit=XML&postal=k1a+0b1: + code: 200 + body: | + + + 45.375437 + -75.691041 + K1A0B1 + + 1 + + OTTAWA + ON + 0.9 + + + +/?geoit=XML&postal=Q0Q+0Q0: + code: 200 + body: | + + + + 008 + Your request did not produce any results. Check your spelling and try again. + + + - + Q0Q0Q0 + + 1 + + + + 0.9 + + diff --git a/test/http/geocoder_us.yml b/test/http/geocoder_us.yml index 1e451d60a..de54aa306 100644 --- a/test/http/geocoder_us.yml +++ b/test/http/geocoder_us.yml @@ -1,2 +1,6 @@ -/service/csv?zip=90210: "34.088808, -118.40612, Beverly Hills, CA, 90210" -/service/csv?zip=00000: "1: couldn't find this zip code: 00000! sorry" +/service/csv?zip=90210: + code: 200 + body: "34.088808, -118.40612, Beverly Hills, CA, 90210" +/service/csv?zip=00000: + code: 200 + body: "1: couldn't find this zip code: 00000! sorry" diff --git a/test/http/geonames.yml b/test/http/geonames.yml index 3527e3ced..65356c807 100644 --- a/test/http/geonames.yml +++ b/test/http/geonames.yml @@ -1,222 +1,228 @@ -/search?lang=en&maxRows=20&q=Hoddesdon&username=dummy: | - - - 1 - - Hoddesdon - Hoddesdon - 51.76148 - -0.01144 - 2646807 - GB - United Kingdom - P - PPL - - - -/search?lang=en&maxRows=20&q=Broxbourne&username=dummy: | - - - 17 - - Broxbourne - Broxbourne - 51.74712 - -0.01923 - 2654481 - GB - United Kingdom - P - PPL - - - Broxbourne District - Broxbourne District - 51.73026 - -0.04821 - 7290563 - GB - United Kingdom - A - ADM3 - - - Cheshunt - Cheshunt - 51.70791 - -0.03739 - 2653232 - GB - United Kingdom - P - PPL - - - Hoddesdon - Hoddesdon - 51.76148 - -0.01144 - 2646807 - GB - United Kingdom - P - PPL - - - Waltham Cross - Waltham Cross - 51.68905 - -0.0333 - 2634842 - GB - United Kingdom - P - PPL - - - Goffs Oak - Goffs Oak - 51.71015 - -0.0872 - 2648362 - GB - United Kingdom - P - PPL - - - Wormley - Wormley - 51.7324 - -0.0242 - 2633535 - GB - United Kingdom - P - PPL - - - Broxbourne - Broxbourne - -27.50314 - 151.378 - 8792801 - AU - Australia - S - HMSD - - - Lee Valley White Water Centre - Lee Valley White Water Centre - 51.68814 - -0.01682 - 7670551 - GB - United Kingdom - S - FCL - - - Cheshunt Railway Station - Cheshunt Railway Station - 51.703 - -0.024 - 6952282 - GB - United Kingdom - S - RSTN - - - Theobalds Grove Railway Station - Theobalds Grove Railway Station - 51.692 - -0.035 - 6953715 - GB - United Kingdom - S - RSTN - - - Waltham Cross Railway Station - Waltham Cross Railway Station - 51.685 - -0.027 - 6953801 - GB - United Kingdom - S - RSTN - - - Rye House Station - Rye House Station - 51.76938 - 0.00562 - 6691700 - GB - United Kingdom - S - RSTN - - - Broxbourne Station - Broxbourne Station - 51.74697 - -0.01105 - 6691701 - GB - United Kingdom - S - RSTN - - - Broxbornebury Park - Broxbornebury Park - 51.75252 - -0.03839 - 6286417 - GB - United Kingdom - S - CSTL - - - Marriott Cheshunt - Marriott Cheshunt - 51.7208 - -0.0324 - 6512481 - GB - United Kingdom - S - HTL - - - Cheshunt Community Hospital - Cheshunt Community Hospital - 51.68396 - -0.03951 - 6289233 - GB - United Kingdom - S - HSP - - - -/countrySubdivision?lang=en&lat=51.7632&lng=-0.0076&username=dummy: | - - - - GB - United Kingdom - ENG - England - ENG - 0.0 - - +/search?lang=en&maxRows=20&q=Hoddesdon&username=dummy: + code: 200 + body: | + + + 1 + + Hoddesdon + Hoddesdon + 51.76148 + -0.01144 + 2646807 + GB + United Kingdom + P + PPL + + + +/search?lang=en&maxRows=20&q=Broxbourne&username=dummy: + code: 200 + body: | + + + 17 + + Broxbourne + Broxbourne + 51.74712 + -0.01923 + 2654481 + GB + United Kingdom + P + PPL + + + Broxbourne District + Broxbourne District + 51.73026 + -0.04821 + 7290563 + GB + United Kingdom + A + ADM3 + + + Cheshunt + Cheshunt + 51.70791 + -0.03739 + 2653232 + GB + United Kingdom + P + PPL + + + Hoddesdon + Hoddesdon + 51.76148 + -0.01144 + 2646807 + GB + United Kingdom + P + PPL + + + Waltham Cross + Waltham Cross + 51.68905 + -0.0333 + 2634842 + GB + United Kingdom + P + PPL + + + Goffs Oak + Goffs Oak + 51.71015 + -0.0872 + 2648362 + GB + United Kingdom + P + PPL + + + Wormley + Wormley + 51.7324 + -0.0242 + 2633535 + GB + United Kingdom + P + PPL + + + Broxbourne + Broxbourne + -27.50314 + 151.378 + 8792801 + AU + Australia + S + HMSD + + + Lee Valley White Water Centre + Lee Valley White Water Centre + 51.68814 + -0.01682 + 7670551 + GB + United Kingdom + S + FCL + + + Cheshunt Railway Station + Cheshunt Railway Station + 51.703 + -0.024 + 6952282 + GB + United Kingdom + S + RSTN + + + Theobalds Grove Railway Station + Theobalds Grove Railway Station + 51.692 + -0.035 + 6953715 + GB + United Kingdom + S + RSTN + + + Waltham Cross Railway Station + Waltham Cross Railway Station + 51.685 + -0.027 + 6953801 + GB + United Kingdom + S + RSTN + + + Rye House Station + Rye House Station + 51.76938 + 0.00562 + 6691700 + GB + United Kingdom + S + RSTN + + + Broxbourne Station + Broxbourne Station + 51.74697 + -0.01105 + 6691701 + GB + United Kingdom + S + RSTN + + + Broxbornebury Park + Broxbornebury Park + 51.75252 + -0.03839 + 6286417 + GB + United Kingdom + S + CSTL + + + Marriott Cheshunt + Marriott Cheshunt + 51.7208 + -0.0324 + 6512481 + GB + United Kingdom + S + HTL + + + Cheshunt Community Hospital + Cheshunt Community Hospital + 51.68396 + -0.03951 + 6289233 + GB + United Kingdom + S + HSP + + + +/countrySubdivision?lang=en&lat=51.7632&lng=-0.0076&username=dummy: + code: 200 + body: | + + + + GB + United Kingdom + ENG + England + ENG + 0.0 + + diff --git a/test/http/nominatim.yml b/test/http/nominatim.yml index 443149346..2fd25d184 100644 --- a/test/http/nominatim.yml +++ b/test/http/nominatim.yml @@ -1,45 +1,53 @@ -/search?accept-language=&format=xml&q=Hoddesdon&viewbox=-0.559%2C51.766%2C0.836%2C51.217: | - - - - - -/search?accept-language=&format=xml&q=Broxbourne&viewbox=-0.559%2C51.766%2C0.836%2C51.217: | - - - - - - - -/reverse?accept-language=&lat=51.7632&lon=-0.0076&zoom=15: | - - - Broxbourne, Hertfordshire, East of England, England, United Kingdom - - Broxbourne - Broxbourne - Hertfordshire - East of England - England - United Kingdom - gb - - - -/reverse?accept-language=&lat=51.7632&lon=-0.0076&zoom=17: | - - - Dinant Link Road, Broxbourne, Hertfordshire, East of England, England, EN11 8HX, United Kingdom - - Dinant Link Road - Broxbourne - Broxbourne - Hertfordshire - East of England - England - EN11 8HX - United Kingdom - gb - - +/search?accept-language=&format=xml&q=Hoddesdon&viewbox=-0.559%2C51.766%2C0.836%2C51.217: + code: 200 + body: | + + + + + +/search?accept-language=&format=xml&q=Broxbourne&viewbox=-0.559%2C51.766%2C0.836%2C51.217: + code: 200 + body: | + + + + + + + +/reverse?accept-language=&lat=51.7632&lon=-0.0076&zoom=15: + code: 200 + body: | + + + Broxbourne, Hertfordshire, East of England, England, United Kingdom + + Broxbourne + Broxbourne + Hertfordshire + East of England + England + United Kingdom + gb + + + +/reverse?accept-language=&lat=51.7632&lon=-0.0076&zoom=17: + code: 200 + body: | + + + Dinant Link Road, Broxbourne, Hertfordshire, East of England, England, EN11 8HX, United Kingdom + + Dinant Link Road + Broxbourne + Broxbourne + Hertfordshire + East of England + England + EN11 8HX + United Kingdom + gb + + diff --git a/test/http/npemap.yml b/test/http/npemap.yml index 39c585a13..e9e3f45c4 100644 --- a/test/http/npemap.yml +++ b/test/http/npemap.yml @@ -1,6 +1,10 @@ -/cgi/geocoder.fcgi?format=text&postcode=CV4+7AL: | - # Easting,Northing,Matched Postcode,Latitude,Longitude - 429926,276058,'CV4 7AL',52.381748701968,-1.56176420939232 +/cgi/geocoder.fcgi?format=text&postcode=CV4+7AL: + code: 200 + body: | + # Easting,Northing,Matched Postcode,Latitude,Longitude + 429926,276058,'CV4 7AL',52.381748701968,-1.56176420939232 -/cgi/geocoder.fcgi?format=text&postcode=XX9+9XX: | - Error: Postcode area 'XX' not found, postcode probably invalid +/cgi/geocoder.fcgi?format=text&postcode=XX9+9XX: + code: 200 + body: | + Error: Postcode area 'XX' not found, postcode probably invalid diff --git a/test/test_helper.rb b/test/test_helper.rb index 15b03b4da..0baf92270 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -167,8 +167,8 @@ module ActiveSupport OSM.http_client = Faraday.new do |builder| builder.adapter :test do |stub| - stubs.each do |url, body| - stub.get(url) { |_env| [200, {}, body] } + stubs.each do |url, response| + stub.get(url) { |_env| [response["code"], {}, response["body"]] } end end end -- 2.43.2