| 1 |
|
| 2 |
# $Id: bysellerid.t,v 1.1 2015-09-13 14:30:09 Martin Exp $ |
| 3 |
|
| 4 |
use constant DEBUG_CONTENTS => 0; |
| 5 |
|
| 6 |
use Date::Manip; |
| 7 |
use ExtUtils::testlib; |
| •8 |
use Test::More; |
| 9 |
|
| 10 |
use WWW::Search; |
| 11 |
use WWW::Search::Test; |
| •12 |
|
| 13 |
use blib; |
| 14 |
use WWW::Search::Ebay::BySellerID; |
| 15 |
|
| 16 |
BEGIN { |
| 17 |
unless ($ENV{NO_NETWORK}) { |
| 18 |
no_plan(); |
| 19 |
} |
| 20 |
else { |
| 21 |
plan skip_all => "no network"; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
my $iDebug; |
| 26 |
my $iDump; |
| 27 |
|
| 28 |
tm_new_engine('Ebay::BySellerID'); |
| 29 |
# goto DEBUG_NOW; |
| 30 |
goto CONTENTS if DEBUG_CONTENTS; |
| 31 |
# goto CONTENTS; |
| 32 |
|
| 33 |
diag("Sending 0-page seller ID query..."); |
| 34 |
$iDebug = 0; |
| 35 |
$iDump = 0; |
| 36 |
# This test returns no results (but we should not get an HTTP error): |
| 37 |
WWW::Search::Test::_tm_run_test('normal', $WWW::Search::Test::bogus_query, 0, 0, $iDebug, $iDump, 0); |
| 38 |
|
| 39 |
goto SKIP_MULTI; |
| 40 |
pass('no-op'); |
| 41 |
# DEBUG_NOW: |
| 42 |
pass('no-op'); |
| 43 |
MULTI_RESULT: |
| 44 |
{ |
| 45 |
$TODO = 'WWW::Search::Ebay can not fetch multiple pages'; |
| 46 |
diag("Sending multi-page seller ID query..."); |
| 47 |
$iDebug = 0; |
| 48 |
$iDump = 0; |
| 49 |
# This query returns many pages of results: |
| 50 |
tm_run_test('normal', 'toymom21957', 200, undef, $iDebug); |
| 51 |
cmp_ok(1, '<', $WWW::Search::Test::oSearch->{requests_made}, 'got multiple pages'); |
| 52 |
$TODO = q{}; |
| 53 |
} |
| 54 |
|
| 55 |
DEBUG_NOW: |
| 56 |
pass('no-op'); |
| 57 |
SKIP_MULTI: |
| 58 |
pass('no-op'); |
| 59 |
CONTENTS: |
| 60 |
diag("Sending 1-page seller ID query to check contents..."); |
| 61 |
$iDebug = DEBUG_CONTENTS ? 2 : 0; |
| 62 |
$iDump = 0; |
| 63 |
$WWW::Search::Test::sSaveOnError = q{bysellerid-failed.html}; |
| 64 |
# local $TODO = 'Too hard to find a seller with consistently one page of auctions'; |
| 65 |
tm_run_test('normal', 'oldschool2017', 1, 199, $iDebug, $iDump); |
| 66 |
# Now get the results and inspect them: |
| 67 |
my @ao = $WWW::Search::Test::oSearch->results(); |
| 68 |
cmp_ok(0, '<', scalar(@ao), 'got some results'); |
| 69 |
my @ara = ( |
| 70 |
['url', 'like', qr{\Ahttps?://(cgi|www)\d*\.ebay\.com}, 'URL is really from ebay.com'], |
| 71 |
['title', 'ne', 'q{}', 'Title is not empty'], |
| 72 |
['change_date', 'date', 'change_date is really a date'], |
| 73 |
['description', 'like', qr{Item #\d+;}, 'description contains item #'], |
| 74 |
['description', 'like', qr{\b(\d+|no)\s+bids?}, # }, # Emacs bug |
| 75 |
'result bidcount is ok'], |
| 76 |
['bid_count', 'like', qr{\A\d+\Z}, 'bid_count is a number'], |
| 77 |
); |
| 78 |
WWW::Search::Test::test_most_results(\@ara, 0.95); |
| 79 |
|
| 80 |
__END__ |
| 81 |
|