Debian Codegraph @

ebay/xt/buyitnow.t

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