aboutsummaryrefslogtreecommitdiffstats
path: root/t/Mock/MapItZurich.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2016-03-28 20:38:28 +0200
committerMarius Halden <marius.h@lden.org>2016-03-28 20:38:28 +0200
commit6c1118dbf2c4b15bcfcd77600d36f2389428c75e (patch)
treeda81756a344a89502df5479b860b6f4a24b6ed92 /t/Mock/MapItZurich.pm
parenta2d67ca6de255ff04badb7cb5a62f7d3df3ce293 (diff)
parent4345263c9de752454795ad57323e684e41e702a8 (diff)
Merge tag 'v1.8.1' into fiksgatami-dev
Diffstat (limited to 't/Mock/MapItZurich.pm')
-rw-r--r--t/Mock/MapItZurich.pm43
1 files changed, 43 insertions, 0 deletions
diff --git a/t/Mock/MapItZurich.pm b/t/Mock/MapItZurich.pm
new file mode 100644
index 000000000..ece9a9b22
--- /dev/null
+++ b/t/Mock/MapItZurich.pm
@@ -0,0 +1,43 @@
+package t::Mock::MapItZurich;
+
+use JSON::MaybeXS;
+use Web::Simple;
+
+use mySociety::Locale;
+
+has json => (
+ is => 'lazy',
+ default => sub {
+ JSON->new->pretty->allow_blessed->convert_blessed;
+ },
+);
+
+sub dispatch_request {
+ my $self = shift;
+
+ sub (GET + /areas/**) {
+ my ($self, $areas) = @_;
+ my $response = {
+ "423017" => {"parent_area" => undef, "generation_high" => 4, "all_names" => {}, "id" => 423017, "codes" => {}, "name" => "Zurich", "country" => "G", "type_name" => "OpenStreetMap Layer 8", "generation_low" => 4, "country_name" => "Global", "type" => "O08"}
+ };
+ my $json = $self->json->encode($response);
+ return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
+ },
+
+ sub (GET + /point/**) {
+ my ($self, $point) = @_;
+ my $response = {
+ "423017" => {"parent_area" => undef, "generation_high" => 4, "all_names" => {}, "id" => 423017, "codes" => {}, "name" => "Zurich", "country" => "G", "type_name" => "OpenStreetMap Layer 8", "generation_low" => 4, "country_name" => "Global", "type" => "O08"}
+ };
+ my $json = $self->json->encode($response);
+ return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
+ },
+
+ sub (GET + /area/*/example_postcode) {
+ my ($self, $area) = @_;
+ my $json = $self->json->encode({});
+ return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
+ },
+}
+
+__PACKAGE__->run_if_script;