Astro-SpaceTrack

 view release on metacpan or  search on metacpan

t/query_spacetrack.t  view on Meta::CPAN

    diag 'live test against space track. be aware of their usage guidelines';
    my $skip;
    $skip = site_check( $space_track_domain )	# To make sure we have account
	and plan skip_all	=> $skip;

    $st = Astro::SpaceTrack->new(
	identity	=> ! $ENV{SPACETRACK_USER},
	verify_hostname	=> VERIFY_HOSTNAME,
    );

} else {
    require Mock::LWP::UserAgent;
    Mock::LWP::UserAgent->install_mock();
    note <<'EOD';
Testing against canned data. Set environment variable
SPACETRACK_TEST_LIVE to test against the actual Space Track web site,
and be aware of their usage guidelines.
EOD

    $st = Astro::SpaceTrack->new(
	username	=> 'bogua',
	password	=> 'equally bogus',
	verify_hostname	=> VERIFY_HOSTNAME,
    );
}

$st->set( space_track_version => $desired_content_interface );

## my $username = $st->getv( 'username' );
## my $password = $st->getv( 'password' );

SKIP: {

    is_success( $st, 'login', 'Log in to Space-Track' )
	or skip 'Not logged in', 1;

    my $rslt = HTTP::Response->new();

    not_defined( $st->content_type(), 'Content type should be undef' )
	or diag( 'content_type is ', $st->content_type() );

    not_defined( $st->content_source(), 'Content source should be undef' )
	or diag( 'content_source is ', $st->content_source() );

    not_defined( $st->content_interface(),
	    'Content interface should be undef' )
	or diag 'content_interface is ', $st->content_interface();

    not_defined( $st->content_type( $rslt ), 'Result type should be undef' )
	or diag( 'content_type is ', $st->content_type( $rslt ) );

    not_defined( $st->content_source( $rslt ),
	    'Result source should be undef' )
	or diag( 'content_source is ', $st->content_source( $rslt ) );

    not_defined( $st->content_interface( $rslt ),
	    'Result interface should be undef' )
	or diag 'content_interface is ', $st->content_interface( $rslt );

    is_error( $st, spacetrack => 'fubar',
	404, 'Fetch a non-existent catalog entry' );

    SKIP: {
	is_success_or_skip( $st, spacetrack => 'inmarsat',
	    'Fetch a catalog entry', 3 );

	is $st->content_type(), 'orbit', "Content type is 'orbit'";

	is $st->content_source(), 'spacetrack',
	    "Content source is 'spacetrack'";

	is $st->content_interface(), $desired_content_interface,
	    "Content version is $desired_content_interface";
    }

    SKIP: {
	is_success_or_skip( $st, retrieve => 25544,
	    'Retrieve ISS orbital elements', 3 );

	is $st->content_type(), 'orbit', "Content type is 'orbit'";

	is $st->content_source(), 'spacetrack',
	    "Content source is 'spacetrack'";

	is $st->content_interface(), $desired_content_interface,
	    "Content version is $desired_content_interface";
    }

    SKIP: {
	is_success_or_skip( $st, file => 't/file.dat',
	    'Retrieve orbital elements specified by file', 3 );

	is $st->content_type(), 'orbit', "Content type is 'orbit'";

	is $st->content_source(), 'spacetrack',
	    "Content source is 'spacetrack'";

	is $st->content_interface(), $desired_content_interface,
	    "Content version is $desired_content_interface";
    }

    SKIP: {
	is_success_or_skip( $st, retrieve => '25544-25546',
	    'Retrieve a range of orbital elements', 3 );

	is $st->content_type(), 'orbit', "Content type is 'orbit'";

	is $st->content_source(), 'spacetrack',
	    "Content source is 'spacetrack'";

	is $st->content_interface(), $desired_content_interface,
	    "Content version is $desired_content_interface";
    }

    SKIP: {
	is_success_or_skip( $st, search_name => 'zarya',
	    "Search for name 'zarya'", 3 );

	is $st->content_type(), 'orbit', "Content type is 'orbit'";

	is $st->content_source(), 'spacetrack',



( run in 3.159 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )