aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Open311.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-08-12 17:34:25 +0100
committerStruan Donald <struan@exo.org.uk>2011-08-12 17:34:25 +0100
commit9ecfbd8ddc99fcff5b421f0dfebfb60c2f5a52d4 (patch)
tree3d9b5871fbf0f83a24d77ceed946771697c59ce6 /perllib/Open311.pm
parent5fd2c5c3656ff094ac8c9f083be483f1af947632 (diff)
shuffle problem update code about to make it easier to test and write some tests
Diffstat (limited to 'perllib/Open311.pm')
-rw-r--r--perllib/Open311.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index 9a9ac5eb4..8c26a5cfc 100644
--- a/perllib/Open311.pm
+++ b/perllib/Open311.pm
@@ -10,6 +10,9 @@ use HTTP::Request::Common qw(POST);
has jurisdiction => ( is => 'ro', isa => 'Str' );;
has api_key => ( is => 'ro', isa => 'Str' );
has endpoint => ( is => 'ro', isa => 'Str' );
+has test_mode => ( is => 'ro', isa => 'Bool' );
+has test_uri_used => ( is => 'rw', 'isa' => 'Str' );
+has test_get_returns => ( is => 'rw' );
sub get_service_list {
my $self = shift;
@@ -125,7 +128,13 @@ sub _get {
$uri->path( $uri->path . $path );
$uri->query_form( $params );
- my $content = get( $uri->as_string );
+ my $content;
+ if ( $self->test_mode ) {
+ $content = $self->test_get_returns->{ $path };
+ $self->test_uri_used( $uri->as_string );
+ } else {
+ $content = get( $uri->as_string );
+ }
return $content;
}