test updates, turn down debugging verbosity master
authorivan <ivan>
Wed, 12 Jan 2011 03:19:59 +0000 (03:19 +0000)
committerivan <ivan>
Wed, 12 Jan 2011 03:19:59 +0000 (03:19 +0000)
Changes
lib/Net/GlobalPOPs/MediaServicesAPI.pm
t/41-auditDIDs.t
t/61-getDID.t
t/62-getDIDs.t
t/lib/test_account.pl

diff --git a/Changes b/Changes
index 40b271f..3cfa500 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Net-GlobalPOPs-MediaServicesAPI
 
+0.03    unreleased
+        - test updates, turn down debugging verbosity
+
 0.02    unreleased
         - update for Net::HTTPS::Any 0.10 without HTTP in response code
 
index 88ee0d2..c28f8ea 100644 (file)
@@ -13,11 +13,12 @@ Net::GlobalPOPs::MediaServicesAPI - Interface to GlobalPOPs Media Services API
 
 =cut
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 our $URL     = 'https://www.loginto.us/VOIP/api.pl';
 #could be parsed from URL, if it mattered...
 our $HOST    = 'www.loginto.us';
 our $PATH    = '/VOIP/api.pl';
+our $PORT    = 443; #to allow testing to override
 
 our $AUTOLOAD;
 our $errstr = '';
@@ -73,6 +74,7 @@ sub new {
   my $proto = shift;
   my $class = ref($proto) || $proto;
   my $self = ref($_[0]) ? shift : { @_ };
+  $self->{'debug'} ||= 0;
   bless($self, $class);
 }
 
@@ -145,18 +147,19 @@ sub AUTOLOAD {
   #$output =~ s/\n+/\n/g;
 
   warn "XML Request for $function function:\n$output"
-    if $self->{'debug'};
+    if $self->{'debug'} > 1;
 
   my( $page, $response, %reply_headers ) = https_post(
     'host'         => $HOST,
-    'path'         => $PATH,
+    'port'         => $PORT,
+    'path'         => ($PATH||443),
     'args'         => { 'apidata' => $output, },
     #'content'      => $output,
     #'Content-Type' => 'text/plain',
     #'Content-Type' => 'text/xml',
     #'Content-Type' => 'application/xml',
     #'headers' => {},
-    'debug'        => $self->{'debug'},
+    'debug'        => ( $self->{'debug'} > 1 ? 1 : 0 ),
   );
 
   unless ( $response =~ /^200/i ) {
@@ -165,17 +168,17 @@ sub AUTOLOAD {
   }
 
   warn "XML Response for $function function:\n: $page"
-    if $self->{'debug'};
+    if $self->{'debug'} > 1;
 
   my $hashref = XMLin( $page );
 
   warn "Parsed response for $function funtion:\n". Dumper($hashref)
-    if $self->{'debug'};
+    if $self->{'debug'} > 1;
 
   my $return = $hashref->{'body'};
 
   warn "Returning data:\n". Dumper($return)
-    if $self->{'debug'};
+    if $self->{'debug'} > 1;
 
   $return;
 
index 1a1f43e..8bcd2e8 100644 (file)
@@ -1,24 +1,23 @@
 #!/usr/bin/perl -w
 
-use Test::More; # skip_all => 'wtf';
+use Test::More skip_all => "not working with current test account?";
 
 require 't/lib/test_account.pl';
+require Net::GlobalPOPs::MediaServicesAPI;
 
 my($login, $password) = test_account_or_skip();
-plan tests => 4;
-
-use_ok 'Net::GlobalPOPs::MediaServicesAPI';
+plan tests => 3;
 
 my $debug = $ENV{TEST_VERBOSE};
 
 my $gp = Net::GlobalPOPs::MediaServicesAPI->new( 'login'    => $login,
                                                  'password' => $password,
-                                                 'debug'    => $debug,
+                                                 #'debug'    => $debug,
                                                );
 my $return = $gp->auditDIDs();
 
 use Data::Dumper;
-#diag( Dumper($return) ) if $debug;
+diag( Dumper($return) ); # if $debug;
 
 ok( $return, 'auditDIDs returned something' );
 
index 721db23..fc59f18 100644 (file)
@@ -8,17 +8,16 @@
 use Test::More;
 
 require 't/lib/test_account.pl';
+require Net::GlobalPOPs::MediaServicesAPI;
 
 my($login, $password) = test_account_or_skip();
-plan tests => 2;
-
-use_ok 'Net::GlobalPOPs::MediaServicesAPI';
+plan tests => 1;
 
 my $debug = $ENV{TEST_VERBOSE};
 
 my $gp = Net::GlobalPOPs::MediaServicesAPI->new( 'login'    => $login,
                                                  'password' => $password,
-                                                 'debug'    => $debug,
+                                                 #'debug'    => $debug,
                                                );
 my $return = $gp->getDID();
 
index 7c1d444..35e42be 100644 (file)
@@ -8,17 +8,17 @@
 use Test::More;
 
 require 't/lib/test_account.pl';
+require Net::GlobalPOPs::MediaServicesAPI;
 
 my($login, $password) = test_account_or_skip();
-plan tests => 2;
+plan tests => 1;
 
-use_ok 'Net::GlobalPOPs::MediaServicesAPI';
 
 my $debug = $ENV{TEST_VERBOSE};
 
 my $gp = Net::GlobalPOPs::MediaServicesAPI->new( 'login'    => $login,
                                                  'password' => $password,
-                                                 'debug'    => $debug,
+                                                 #'debug'    => $debug,
                                                );
 my $return = $gp->getDIDs(
   'state'   => 'CA',
@@ -28,7 +28,7 @@ my $return = $gp->getDIDs(
 );
 
 use Data::Dumper;
-diag( Dumper($return) ) if $debug;
+diag( Dumper($return) ); # if $debug;
 
 #XXX test some things about the return...
 ok( $return, 'getDIDs returned something' );
index 4b316db..b4fa603 100644 (file)
@@ -12,9 +12,16 @@ sub test_account_or_skip {
 
 sub test_account {
     open TEST_ACCOUNT, "t/test_account" or return;
-    my($login, $password) = <TEST_ACCOUNT>;
+    my($login, $password, $hostport) = <TEST_ACCOUNT>;
     chomp $login;
     chomp $password;
+    chomp $hostport;
+
+    if ( $hostport =~ /^\s*([\w\.]+)(:(\d+))?\s*$/ ) {
+      my($host, $port) = ($1, $3);
+      $Net::GlobalPOPs::MediaServicesAPI::HOST = $host;
+      $Net::GlobalPOPs::MediaServicesAPI::PORT = $port;
+    }
 
     return($login, $password);
 }