summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-12-12 16:31:06 -0800
committerIvan Kohler <ivan@freeside.biz>2012-12-12 16:31:06 -0800
commit1d339ad33855e8df8c1f466b494acbfd0e0907da (patch)
treea4a609605840d1ebf666e651efd41663d8f7da83 /t
initial commit
Diffstat (limited to 't')
-rw-r--r--t/00-load.t9
-rw-r--r--t/01-login.t17
-rw-r--r--t/41-auditDIDs.t53
-rw-r--r--t/61-getDID.t28
-rw-r--r--t/62-getDIDs.t34
-rw-r--r--t/lib/test_account.pl29
-rw-r--r--t/pod-coverage.t18
-rw-r--r--t/pod.t12
8 files changed, 200 insertions, 0 deletions
diff --git a/t/00-load.t b/t/00-load.t
new file mode 100644
index 0000000..ddd413c
--- /dev/null
+++ b/t/00-load.t
@@ -0,0 +1,9 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok( 'Net::VoIP_Innovations' );
+}
+
+diag( "Testing Net::VoIP_Innovations $Net::VoIP_Innovations::VERSION, Perl $], $^X" );
diff --git a/t/01-login.t b/t/01-login.t
new file mode 100644
index 0000000..2642b59
--- /dev/null
+++ b/t/01-login.t
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+
+use Test::More;
+require 't/lib/test_account.pl';
+
+my($login, $password) = test_account_or_skip;
+plan tests => 2;
+
+use_ok 'Net::VoIP_Innovations';
+
+my $gp = Net::VoIP_Innovations->new('login' => $login,
+ 'password' => $password );
+
+#eww. what is the right, TEST_VERBOSE-aware way to do this
+warn Net::VoIP_Innovations->errstr unless $gp;
+
+ok( $gp, 'Login sucessful' );
diff --git a/t/41-auditDIDs.t b/t/41-auditDIDs.t
new file mode 100644
index 0000000..6793931
--- /dev/null
+++ b/t/41-auditDIDs.t
@@ -0,0 +1,53 @@
+#!/usr/bin/perl -w
+
+use Test::More skip_all => "not working with current test account?";
+
+require 't/lib/test_account.pl';
+require Net::VoIP_Innovations;
+
+my($login, $password) = test_account_or_skip();
+plan tests => 3;
+
+my $debug = $ENV{TEST_VERBOSE};
+
+my $gp = Net::VoIP_Innovations->new( 'login' => $login,
+ 'password' => $password,
+ #'debug' => $debug,
+ );
+my $return = $gp->auditDIDs();
+
+use Data::Dumper;
+diag( Dumper($return) ); # if $debug;
+
+ok( $return, 'auditDIDs returned something' );
+
+# 'did' => [
+# {
+# 'statuscode' => '100',
+# 'status' => 'Number currently assigned to you with refid rewritten as \'\' to endpoint 521',
+# 'cnam' => 'False',
+# 'expire_seconds' => {},
+# 'availability' => 'assigned',
+# 'tn' => '2137851430',
+# 'rewrite' => {},
+# 'endpoint' => '521',
+# 'refid' => {}
+# },
+# {
+# 'statuscode' => '100',
+# 'status' => 'Number currently assigned to you with refid rewritten as \'\' to endpoint 521',
+# 'cnam' => 'False',
+# 'expire_seconds' => {},
+# 'availability' => 'assigned',
+# 'tn' => '5109626974',
+# 'rewrite' => {},
+# 'endpoint' => '521',
+# 'refid' => {}
+# }
+# ]
+
+
+ok( $return->{'did'}, 'auditDIDs returned did data' );
+
+ok( ref($return->{'did'}) eq 'ARRAY', 'auditDIDs did data is a list' );
+
diff --git a/t/61-getDID.t b/t/61-getDID.t
new file mode 100644
index 0000000..15dfe54
--- /dev/null
+++ b/t/61-getDID.t
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+
+#BEGIN {
+# $Net::HTTPS::Any::skip_NetSSLeay = 1;
+# $Net::HTTPS::Any::skip_NetSSLeay = 1;
+#}
+
+use Test::More;
+
+require 't/lib/test_account.pl';
+require Net::VoIP_Innovations;
+
+my($login, $password) = test_account_or_skip();
+plan tests => 1;
+
+my $debug = $ENV{TEST_VERBOSE};
+
+my $gp = Net::VoIP_Innovations->new( 'login' => $login,
+ 'password' => $password,
+ #'debug' => $debug,
+ );
+my $return = $gp->getDID();
+
+use Data::Dumper;
+diag( Dumper($return) ) if $debug;
+
+#XXX test some things about the return...
+ok( $return, 'getDID returned something' );
diff --git a/t/62-getDIDs.t b/t/62-getDIDs.t
new file mode 100644
index 0000000..52f0170
--- /dev/null
+++ b/t/62-getDIDs.t
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w
+
+#BEGIN {
+# $Net::HTTPS::Any::skip_NetSSLeay = 1;
+# $Net::HTTPS::Any::skip_NetSSLeay = 1;
+#}
+
+use Test::More;
+
+require 't/lib/test_account.pl';
+require Net::VoIP_Innovations;
+
+my($login, $password) = test_account_or_skip();
+plan tests => 1;
+
+
+my $debug = $ENV{TEST_VERBOSE};
+
+my $gp = Net::VoIP_Innovations->new( 'login' => $login,
+ 'password' => $password,
+ #'debug' => $debug,
+ );
+my $return = $gp->getDIDs(
+ 'state' => 'CA',
+ 'lata' => '722',
+ #'npa' => '415',
+ 'orderby' => 'ORDER BY npa', #?
+);
+
+use Data::Dumper;
+diag( Dumper($return) ); # if $debug;
+
+#XXX test some things about the return...
+ok( $return, 'getDIDs returned something' );
diff --git a/t/lib/test_account.pl b/t/lib/test_account.pl
new file mode 100644
index 0000000..c52067d
--- /dev/null
+++ b/t/lib/test_account.pl
@@ -0,0 +1,29 @@
+use Test::More;
+
+sub test_account_or_skip {
+ my($login, $password) = test_account();
+
+ unless( defined $login ) {
+ plan skip_all => "No test account";
+ }
+
+ return($login, $password);
+}
+
+sub test_account {
+ open TEST_ACCOUNT, "t/test_account" or return;
+ my($login, $password, $hostport) = <TEST_ACCOUNT>;
+ chomp $login;
+ chomp $password;
+ chomp $hostport;
+
+ if ( $hostport =~ /^\s*([\w\.]+)(:(\d+))?\s*$/ ) {
+ my($host, $port) = ($1, $3);
+ $Net::VoIP_Innovations::HOST = $host;
+ $Net::VoIP_Innovations::PORT = $port;
+ }
+
+ return($login, $password);
+}
+
+1;
diff --git a/t/pod-coverage.t b/t/pod-coverage.t
new file mode 100644
index 0000000..fc40a57
--- /dev/null
+++ b/t/pod-coverage.t
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod::Coverage
+my $min_tpc = 1.08;
+eval "use Test::Pod::Coverage $min_tpc";
+plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
+ if $@;
+
+# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
+# but older versions don't recognize some common documentation styles
+my $min_pc = 0.18;
+eval "use Pod::Coverage $min_pc";
+plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
+ if $@;
+
+all_pod_coverage_ok();
diff --git a/t/pod.t b/t/pod.t
new file mode 100644
index 0000000..ee8b18a
--- /dev/null
+++ b/t/pod.t
@@ -0,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();