aboutsummaryrefslogtreecommitdiffstats
path: root/t/Mock
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-03-23 11:44:39 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-03-23 11:44:39 +0000
commitf1b3e509455163b0f3362e460d201d04593a8388 (patch)
treeed5833d16c4142a45fb20ff8b8227aeafefbea78 /t/Mock
parent4210219bed15cbd76c9e351db160f1d0188f78f8 (diff)
parentb33eb7d3bd02ece9ff70a215290a233f6e480378 (diff)
Merge branch 'perl5.22-snapshot-update'
Diffstat (limited to 't/Mock')
-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;