diff options
author | Marius Halden <marius.h@lden.org> | 2020-09-29 14:23:52 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2020-09-29 14:23:52 +0200 |
commit | a27ce1524d801d2742a2bdb6ec1da45126d64353 (patch) | |
tree | 64123c4e17dc1776aa0a7cd65ee01d49d3e7d978 /t/geocode | |
parent | 377bd96aab7cad3434185c30eb908c9da447fe40 (diff) | |
parent | 2773c60226b9370fe8ee00f7b205b571bb87c3b5 (diff) |
Merge tag 'v3.0.1' into fiksgatami-dev
Diffstat (limited to 't/geocode')
-rw-r--r-- | t/geocode/google.t | 4 | ||||
-rw-r--r-- | t/geocode/highwaysengland.t | 108 | ||||
-rw-r--r-- | t/geocode/roads.sqlite | bin | 0 -> 62464 bytes |
3 files changed, 110 insertions, 2 deletions
diff --git a/t/geocode/google.t b/t/geocode/google.t index ee3c15ea8..40e8caf9a 100644 --- a/t/geocode/google.t +++ b/t/geocode/google.t @@ -11,12 +11,12 @@ use Catalyst::Test 'FixMyStreet::App'; use t::Mock::GoogleGeocoder; my $c = ctx_request('/'); -my $r = FixMyStreet::Geocode::Google::string("one result", $c); +my $r = FixMyStreet::Geocode::Google->string("one result", $c); ok $r->{latitude}; ok $r->{longitude}; $c->stash->{cobrand} = FixMyStreet::Cobrand::Tester->new; -$r = FixMyStreet::Geocode::Google::string("two results", $c); +$r = FixMyStreet::Geocode::Google->string("two results", $c); is scalar @{$r->{error}}, 2; done_testing; diff --git a/t/geocode/highwaysengland.t b/t/geocode/highwaysengland.t new file mode 100644 index 000000000..7380a8437 --- /dev/null +++ b/t/geocode/highwaysengland.t @@ -0,0 +1,108 @@ +use FixMyStreet::Test; +use HighwaysEngland; +use Test::MockModule; + +my $he = Test::MockModule->new('HighwaysEngland'); +$he->mock('database_file', sub { FixMyStreet->path_to('t/geocode/roads.sqlite'); }); + + +for my $test ( + { + search => 'M1, Jct 16', + latitude => 52.2302496115401, + long => -1.01582565724738, + desc => 'junction number second' + }, + { + search => 'Jct 16, M1', + latitude => 52.2302496115401, + long => -1.01582565724738, + desc => 'junction number first' + }, + { + search => 'M1 Jct 16', + latitude => 52.2302496115401, + long => -1.01582565724738, + desc => 'no comma as separator' + }, + { + search => 'M1 Jct16', + latitude => 52.2302496115401, + long => -1.01582565724738, + desc => 'no space in junction name' + }, + { + search => 'M1 J16', + latitude => 52.2302496115401, + long => -1.01582565724738, + desc => 'J for junction' + }, + { + search => 'M1 Junction 16', + latitude => 52.2302496115401, + long => -1.01582565724738, + desc => 'junction as word' + }, + { + search => 'm1 j16', + latitude => 52.2302496115401, + long => -1.01582565724738, + desc => 'lower case search' + }, + { + search => 'A1, B668', + latitude => 52.7323808633713, + long => -0.599568322474905, + desc => 'road with joining road second' + }, + { + search => ' B668, A1', + latitude => 52.7323808633713, + long => -0.599568322474905, + desc => 'road with joining road first' + }, + { + search => 'A1, A607', + latitude => 52.8975982569244, + long => -0.664016143160206, + desc => 'road with joining A road' + }, + { + search => 'A1, Long Bennington', + latitude => 52.979716221406, + long => -0.746100037226323, + desc => 'road with junction town' + }, + { + search => 'Long Bennington, A1', + latitude => 52.979716221406, + long => -0.746100037226323, + desc => 'road with junction town first' + }, + { + search => 'A14, J2', + latitude => 52.3998144608558, + long => -0.916447519667833, + desc => 'road with more than one number' + }, + { + search => 'Watford gap services', + latitude => 52.3068680406392, + long => -1.1219749609866, + desc => 'motorway services' + }, + { + search => 'M1 42.1', + latitude => 51.7926609391213, + long => -0.411879446242646, + desc => 'road and distance' + }, +) { + subtest $test->{desc} => sub { + my $r = HighwaysEngland::junction_lookup($test->{search}); + is $r->{latitude}, $test->{latitude}, 'correct latitude'; + is $r->{longtude}, $test->{longtude}, 'correct longtude'; + }; +} + +done_testing; diff --git a/t/geocode/roads.sqlite b/t/geocode/roads.sqlite Binary files differnew file mode 100644 index 000000000..09cd0c9a7 --- /dev/null +++ b/t/geocode/roads.sqlite |