Debian Codegraph @

ebay/t/enddate.t

raw ◀ ▶
1 Debian patch touch this file
1
2 my $VERSION = 1.16;
3
4 use strict;
5 use warnings;
6
7 use blib;
8 use Data::Dumper;
9 use Date::Manip;
10 $ENV{TZ} = 'EST5EDT';
11 # Date_Init('TZ=EST5EDT');
12 use ExtUtils::testlib;
13 use Test::More;
14 use WWW::Search;
15 use WWW::Search::Test;
16
•17 use WWW::Search::Ebay::ByEndDate;
18
19 BEGIN {
20 unless ($ENV{NO_NETWORK}) {
21 no_plan();
22 }
23 else {
24 plan skip_all => "no network";
25 }
26 }
27
28 use constant DEBUG_DATE => 0;
29
30 my $iDebug = 0;
31 my $iDump = 0;
32
33 tm_new_engine('Ebay::ByEndDate');
34 # goto TEST_NOW;
35
36 pass('no-op');
37 TEST_NOW:
38 pass('no-op');
39 diag("Sending end-date query...");
40 $iDebug = 0;
41 $iDump = 0;
42 $WWW::Search::Test::sSaveOnError = q{enddate-failed.html};
43 # We need a query that returns "Featured Items" _and_ items that end
44 # in a few minutes. This one attracts Rock'n'Roll fans and
45 # philatelists:
46 TODO:
47 {
48 $TODO = 'We only need one page of results in order to test the end-date sort';
49 tm_run_test('normal', 'zeppelin', 45, 49, $iDebug, $iDump);
50 }
51 $TODO = '';
52 # goto ALL_DONE; # for debugging
53
54 # Now get some ByEndDate results and inspect them:
55 my @ao = $WWW::Search::Test::oSearch->results();
56 cmp_ok(0, '<', scalar(@ao), 'got some results');
57 my $sDatePrev = 'yesterday';
58 foreach my $oResult (@ao)
59 {
60 like($oResult->url, qr{\Ahttps?://(cgi|www)\d*\.ebay\.com},
61 'result URL really is from ebay.com');
62 my $sTitle = $oResult->title;
63 cmp_ok($sTitle, 'ne', '',
64 qq'result Title ($sTitle) is not empty');
65 like($oResult->description, qr{([0-9]+|no)\s+bids?},
66 'result bidcount is ok');
67 my $sDate = $oResult->end_date || '';
68 DEBUG_DATE && diag(qq{raw end date is '$sDate'});
69 diag(Dumper($oResult)) unless isnt($sDate, '', "end_date ($sDate) is not empty");
70 # It is not possible to test the order of results in this way,
71 # because eBay sometimes sticks paid (advertised) auctions at the
72 # top of the page (and those are not in order).
73 my $iCmp = Date_Cmp($sDatePrev, $sDate);
74 # cmp_ok($iCmp, '<=', 0, 'result is in order by end date');
75 $sDatePrev = $sDate;
76 } # foreach
77 pass('no-op');
78 ALL_DONE:
79 pass('no-op');
80
81 done_testing();
82
83 __END__
84