1# Astro::ADS::Query test harness 2 3use strict; 4use Test::More tests => 22; 5use Astro::ADS::Query; 6use Astro::ADS::Result; 7 8# T E S T H A R N E S S -------------------------------------------------- 9my $timestamp = join ':', (localtime)[2,1,0]; 10my $wait = 5; # seconds to wait before subsequent calls to ADS 11 12# list of authors 13my @authors = ( "Allan, Alasdair", "Naylor, Tim", "Harries, T.J.", "Bate, M."); 14 15# Check the configuration of the Query object 16my $query = new Astro::ADS::Query( Authors => \@authors ); 17$query->agent("Test Suite $timestamp"); 18 19# Proxy 20my $proxy = $query->proxy(); 21if ($proxy ) { 22 diag("You are using $proxy as a web proxy"); 23} 24else { 25 diag("No web proxy in use"); 26} 27is( $query->proxy(undef), undef, 'Unset proxy'); 28 29 30# AUTHORS 31my @ret_authors = $query->authors(); 32is_deeply(\@ret_authors, \@authors, "check its got all the authors"); 33my $first_author = $query->authors(); 34is( $first_author, $authors[0], "scalar call to authors returns the first author" ); 35 36# delete two authors and check again 37my @new_authors = @authors[0,1]; 38my @next_authors = $query->authors(\@new_authors); 39is_deeply( \@next_authors, \@new_authors, "delete two authors and check again that it got all its authors"); 40my $new_first_author = $query->authors(); 41is( $new_first_author, $new_authors[0], "check authors in scalar context" ); 42 43# change author logic 44my $author_logic = $query->authorlogic("AND"); 45is( $author_logic, "AND", "Check author logic" ); 46 47 48# query ADS 49diag("First query to ADS (authors)"); 50my $result = $query->querydb(); 51 52# grab the comparison from the DATA block - NEVER USED, WHY?!? 53my @data = <DATA>; 54chomp @data; 55 56# change author logic 57$author_logic = $query->authorlogic("OR"); 58is( $author_logic, "OR", "check author login" ); 59 60# list of objects 61my @objects = ( "U Gem", "SS Cyg"); 62 63# Check the configuration of the Query object 64my $query2 = new Astro::ADS::Query( Objects => \@objects, proxy => $query->proxy() ); 65$query2->agent("Test Suite $timestamp"); 66 67my @ret_obj = $query2->objects(); 68is_deeply(\@ret_obj, \@objects, "Check the configuration of the Query object"); 69 70# change author logic 71my $obj_logic = $query2->objectlogic("AND"); 72is( $obj_logic, "AND", "check the author logic" ); 73 74 75# query ADS (2) 76diag("Second query to ADS - searching on ", join " and ", @objects); 77sleep $wait; 78my $other_result = $query2->querydb(); 79 80is( $other_result->sizeof(), 100, 'Should get 100 abstracts per page (this paper returns 304 results)'); 81 82# add some more objects 83$objects[2] = "M31"; 84$objects[3] = "M32"; 85 86diag("Third query with additional objects ($objects[2] and $objects[3])"); 87my $query3 = new Astro::ADS::Query( Objects => \@objects, proxy => $query->proxy() ); 88$query3->agent("Test Suite $timestamp"); 89$query3->objectlogic("AND"); 90 91# Set the object query 92$query3->objects( \@objects ); 93 94 95# query ADS (3) 96sleep $wait; 97my $next_result = $query3->querydb(); 98 99is( $next_result->sizeof(), 0, 'Should have no results with those 4 objects' . join ", ", @objects); 100 101# set and check the proxy 102$query2->proxy('http://wwwcache.ex.ac.uk:8080/'); 103is( $query2->proxy(), 'http://wwwcache.ex.ac.uk:8080/', 'Should return the proxy just set'); 104 105# set and check the timeout 106$query2->timeout(60); 107is( $query2->timeout(), 60, 'checking timeout on the user agent' ); 108 109# test bibcode query for Tim Jenness 110diag("Fourth query for Tim Jenness' paper 1996PhDT........42J"); 111my $query4 = new Astro::ADS::Query( Bibcode => "1996PhDT........42J", proxy => $query->proxy() ); 112$query4->agent("Test Suite $timestamp"); 113 114# query ADS 115sleep $wait; 116my $bibcode_result = $query4->querydb(); 117 118# check we have the right object 119# 120# TODO: Should get the abstract and match test against that 121# 122my $timj_thesis = $bibcode_result->paperbyindex( 0 ); 123my @timj_abstract = $timj_thesis->abstract(); 124cmp_ok( @timj_abstract, ">=", 33, "number of lines of text for Tim Jenness' abstract" ); 125#open my $fh, '>', 't/timj_abstract.txt'; 126#print $fh @timj_abstract, "\n"; 127#close $fh; 128 129# test the user agent tag 130diag("User Agent: ", $query4->agent() ); 131 132# Test the start/end year and month options 133$query4->startmonth( "01" ); 134is( $query4->startmonth(), "01", 'Start month option' ); 135 136$query4->endmonth( "12" ); 137is( $query4->endmonth(), "12", 'End month option' ); 138 139$query4->startyear( "2001" ); 140is( $query4->startyear(), "2001", 'Start year option' ); 141 142$query4->endyear( "2002" ); 143is( $query4->endyear(), "2002", 'End year option' ); 144 145# test the ampersand bibcode bug rt #35645( affects Astronomy & Astrophysics ) 146my $bibcode5 = '1977A&A....60...43D'; 147diag("Fifth query for $bibcode5"); 148my $query5 = new Astro::ADS::Query( Bibcode => $bibcode5, proxy => $query->proxy() ); 149$query5->agent("Test Suite $timestamp"); 150 151sleep $wait; 152my $AnA_bibcode_result = $query5->querydb(); 153 154# check we have the right object 155my $AnA_paper = $AnA_bibcode_result->paperbyindex( 0 ); 156my $AnA_title = $AnA_paper->title(); 157my $AnA_bibcode = $AnA_paper->bibcode(); 158 159# title from Web search 160is( $AnA_title, 'NGC 1510 - A young elliptical galaxy', 'Title from Web search' ); 161is( $AnA_bibcode, $bibcode5, "bibcodes should match $bibcode5" ); 162 163diag("Call reference method on $AnA_bibcode"); 164my $AnA_references = $AnA_paper->references(); 165is( $AnA_references->sizeof(), 39, 'check the references with ampersand in bibcode' ); 166is( $AnA_references->paperbyindex(2)->bibcode(), '1973A&A....29...43B', 'Third reference should be the 1973 Astronomy & Astrophysics paper'); 167 168done_testing; 169exit; 170 171# D A T A B L O C K ---------------------------------------------------- 172 173__DATA__ 174Query Results from the Astronomy Database 175 176 177Retrieved 1 abstracts, starting with number 1. Total number selected: 1. 178 179%R 1999MNRAS.310..407W 180%T A spatially resolved `inside-out' outburst of IP Pegasi 181%A Webb, N. A.; Naylor, T.; Ioannou, Z.; Worraker, W. J.; Stull, J.; Allan, A.; 182Fried, R.; James, N. D.; Strange, D. 183%F AA(Department of Physics, Keele University, Keele, Staffordshire ST5 5BG), 184AB(Department of Physics, Keele University, Keele, Staffordshire ST5 5BG), 185AC(Department of Physics, Keele University, Keele, Staffordshire ST5 5BG), 186AD(65 Wantage Road, Didcot, Oxfordshire OX11 0AE), AE(Stull Observatory, 187Alfred University, Alfred, NY 14802, USA), AF(Department of Physics, Keele 188University, Keele, Staffordshire ST5 5BG), AG(Braeside Observatory, PO Box 189906 Flagstaff, AZ 86002, USA), AH(11 Tavistock Road, Chelmsford, Essex CM1 1906JL), AI(Worth Hill Observatory, Worth Matravers, Dorset) 191%J Monthly Notices, Volume 310, Issue 2, pp. 407-413. 192%D 12/1999 193%L 413 194%K ACCRETION, ACCRETION DISCS, BINARIES: ECLIPSING, STARS: INDIVIDUAL: IP PEG, 195NOVAE, CATACLYSMIC VARIABLES, WHITE DWARFS, INFRARED: STARS 196%G MNRAS 197%C (c) 1999 The Royal Astronomical Society 198%I ABSTRACT: Abstract; 199 EJOURNAL: Electronic On-line Article; 200 ARTICLE: Full Printable Article; 201 REFERENCES: References in the Article; 202 CITATIONS: Citations to the Article; 203 SIMBAD: SIMBAD Objects; 204%U http://cdsads.u-strasbg.fr/cgi-bin/nph-bib_query?bibcode=1999MNRAS.310..407W&db_key=AST 205%S 1.000 206%B We present a comprehensive photometric data set taken over the entire 207outburst of the eclipsing dwarf nova IP Peg in 1997 September/October. 208Analysis of the light curves taken over the long rise to the 209peak-of-outburst shows conclusively that the outburst started near the 210centre of the disc and moved outwards. This is the first data set that 211spatially resolves such an outburst. The data set is consistent with the 212idea that long rise times are indicative of such `inside-out' outbursts. 213We show how the thickness and the radius of the disc, along with the 214mass transfer rate, change over the whole outburst. In addition, we show 215evidence of the secondary and the irradiation thereof. We discuss the 216possibility of spiral shocks in the disc; however, we find no conclusive 217evidence of their existence in this data set. 218