| 1 |
|
| 2 |
# $Id: buyitnow.t,v 1.1 2015-09-13 14:30:09 Martin Exp $ |
| 3 |
|
| 4 |
use blib; |
| 5 |
use Bit::Vector; |
| 6 |
use Data::Dumper; |
| 7 |
use Date::Manip; |
| •8 |
use Test::More; |
| 9 |
|
| 10 |
use WWW::Search::Test; |
| •11 |
use WWW::Search::Ebay::BuyItNow; |
| 12 |
|
| 13 |
BEGIN { |
| 14 |
unless ($ENV{NO_NETWORK}) { |
| 15 |
no_plan(); |
| 16 |
} |
| 17 |
else { |
| 18 |
plan skip_all => "no network"; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
my $iDebug; |
| 23 |
my $iDump = 0; |
| 24 |
|
| 25 |
tm_new_engine('Ebay::BuyItNow'); |
| 26 |
# goto MULTI_RESULT; |
| 27 |
# goto DEBUG_NOW; |
| 28 |
# goto CONTENTS; |
| 29 |
|
| 30 |
diag("Sending 0-page buy-it-now query..."); |
| 31 |
$iDebug = 0; |
| 32 |
# This test returns no results (but we should not get any error): |
| 33 |
WWW::Search::Test::_tm_run_test('normal', $WWW::Search::Test::bogus_query, 0, 0, $iDebug, 0); |
| 34 |
|
| 35 |
# DEBUG_NOW: |
| 36 |
pass; |
| 37 |
MULTI_RESULT: |
| 38 |
{ |
| 39 |
$TODO = 'WWW::Search::Ebay can not fetch multiple pages'; |
| 40 |
diag("Sending multi-page buy-it-now query..."); |
| 41 |
$iDebug = 0; |
| 42 |
$iDump = 0; |
| 43 |
# This query returns hundreds of pages of results: |
| 44 |
tm_run_test('normal', 'LEGO', 222, undef, $iDebug); |
| 45 |
cmp_ok(1, '<', $WWW::Search::Test::oSearch->{requests_made}, 'got multiple pages'); |
| 46 |
$TODO = ''; |
| 47 |
} |
| 48 |
|
| 49 |
# DEBUG_NOW: |
| 50 |
pass; |
| 51 |
TODO: |
| 52 |
{ |
| 53 |
$TODO = 'sometimes there are too many of this book for sale'; |
| 54 |
diag("Sending 1-page buy-it-now query for 12-digit UPC..."); |
| 55 |
$iDebug = 0; |
| 56 |
$iDump = 0; |
| 57 |
tm_run_test('normal', '0-77778-60672-7' , 1, 99, $iDebug, $iDump); |
| 58 |
$TODO = ''; |
| 59 |
} # end of TODO |
| 60 |
pass; |
| 61 |
TODO: |
| 62 |
{ |
| 63 |
$TODO = 'sometimes there are zero of this item'; |
| 64 |
diag("Sending 1-page buy-it-now query for 13-digit EAN..."); |
| 65 |
$iDebug = 0; |
| 66 |
$iDump = 0; |
| 67 |
tm_run_test('normal', '00-75678-26382-8' , 1, 99, $iDebug, $iDump); |
| 68 |
$TODO = ''; |
| 69 |
} |
| 70 |
DEBUG_NOW: |
| 71 |
diag("Sending 1-page buy-it-now query for 10-digit ISBN..."); |
| 72 |
TODO: |
| 73 |
{ |
| 74 |
$TODO = 'sometimes there are none of this book for sale'; |
| 75 |
$iDebug = 0; |
| 76 |
$iDump = 0; |
| 77 |
tm_run_test('normal', '0-395-52021-5' , 1, 99, $iDebug, $iDump); |
| 78 |
$TODO = ''; |
| 79 |
} # end of TODO block |
| 80 |
# goto SKIP_CONTENTS; |
| 81 |
|
| 82 |
CONTENTS: |
| 83 |
diag("Sending 1-page buy-it-now query to check contents..."); |
| 84 |
$iDebug = 0; |
| 85 |
$iDump = 0; |
| 86 |
$WWW::Search::Test::sSaveOnError = q{buyitnow-failed.html}; |
| 87 |
tm_run_test('normal', 'Kenya waterfall', 1, 199, $iDebug, $iDump); |
| 88 |
# Now get the results and inspect them: |
| 89 |
my @ao = $WWW::Search::Test::oSearch->results(); |
| 90 |
cmp_ok(0, '<', scalar(@ao), 'got some results'); |
| 91 |
my @ara; |
| 92 |
push @ara, [ |
| 93 |
url => like => qr{\Ahttps?://(cgi|www)\d*\.ebay\.com}, |
| 94 |
'result URL is really from ebay.com' |
| 95 |
]; |
| 96 |
push @ara, [ |
| 97 |
title => ne => q{''}, 'result title is not empty', |
| 98 |
]; |
| 99 |
push @ara, [ |
| 100 |
description => like => qr{no\s+bids;}, 'bid count is ok', |
| 101 |
]; |
| 102 |
push @ara, [ |
| 103 |
description => like => qr{starting\sbid}, 'result bid amount is ok' |
| 104 |
]; |
| 105 |
WWW::Search::Test::test_most_results(\@ara); |
| 106 |
SKIP_CONTENTS: |
| 107 |
; |
| 108 |
|
| 109 |
__END__ |
| 110 |
|