aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/cobrand/bucks.t2
-rw-r--r--t/cobrand/westminster.t52
2 files changed, 52 insertions, 2 deletions
diff --git a/t/cobrand/bucks.t b/t/cobrand/bucks.t
index 6732eb29c..2d42dcd81 100644
--- a/t/cobrand/bucks.t
+++ b/t/cobrand/bucks.t
@@ -19,7 +19,7 @@ $mech->create_contact_ok(body_id => $district->id, category => 'Graffiti', email
my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Buckinghamshire');
$cobrand->mock('lookup_site_code', sub {
- my ($self, $row, $buffer) = @_;
+ my ($self, $row) = @_;
return "Road ID" if $row->latitude == 51.812244;
});
diff --git a/t/cobrand/westminster.t b/t/cobrand/westminster.t
index 756b9720c..2912f6ee5 100644
--- a/t/cobrand/westminster.t
+++ b/t/cobrand/westminster.t
@@ -7,7 +7,7 @@ ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
my $cobrand = Test::MockModule->new('FixMyStreet::Cobrand::Westminster');
$cobrand->mock('lookup_site_code', sub {
- my ($self, $row, $buffer) = @_;
+ my ($self, $row) = @_;
return "My USRN" if $row->latitude == 51.501009;
});
@@ -165,4 +165,54 @@ FixMyStreet::override_config {
};
};
+my $westminster = FixMyStreet::Cobrand::Westminster->new;
+subtest 'correct config returned for USRN/UPRN lookup' => sub {
+ my $actual = $westminster->lookup_site_code_config('USRN');
+ delete $actual->{accept_feature}; # is_deeply doesn't like code
+ is_deeply $actual, {
+ buffer => 1000,
+ proxy_url => "https://tilma.staging.mysociety.org/resource-proxy/proxy.php",
+ url => "https://westminster.assets/40/query",
+ property => 'USRN',
+ };
+ $actual = $westminster->lookup_site_code_config('UPRN');
+ delete $actual->{accept_feature}; # is_deeply doesn't like code
+ is_deeply $actual, {
+ buffer => 1000,
+ proxy_url => "https://tilma.staging.mysociety.org/resource-proxy/proxy.php",
+ url => "https://westminster.assets/25/query",
+ property => 'UPRN',
+ accept_types => {
+ Point => 1
+ },
+ };
+};
+
+subtest 'nearest UPRN returns correct point' => sub {
+ my $cfg = {
+ accept_feature => sub { 1 },
+ property => 'UPRN',
+ accept_types => {
+ Point => 1,
+ },
+ };
+ my $features = [
+ # A couple of incorrect geometry types to check they're ignored...
+ { geometry => { type => 'Polygon' } },
+ { geometry => { type => 'LineString',
+ coordinates => [ [ 527735, 181004 ], [ 527755, 181004 ] ] },
+ properties => { fid => '20100024' } },
+ # And two points which are further away than the above linestring,
+ # the second of which is the closest to our testing point.
+ { geometry => { type => 'Point',
+ coordinates => [ 527795, 181024 ] },
+ properties => { UPRN => '10012387122' } },
+ { geometry => { type => 'Point',
+ coordinates => [ 527739, 181009 ] },
+ properties => { UPRN => '10012387123' } },
+ ];
+ is $westminster->_nearest_feature($cfg, 527745, 180994, $features), '10012387123';
+};
+
+
done_testing();