Debian Codegraph @

ebay/t/enddate.t

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
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 constant DEBUG_DATE => 0;
18
19 my $iDebug = 0;
20 my $iDump = 0;
21
22 tm_new_engine('Ebay::ByEndDate');
23 # goto TEST_NOW;
24
25 pass('no-op');
26 TEST_NOW:
27 pass('no-op');
28 diag("Sending end-date query...");
29 $iDebug = 0;
30 $iDump = 0;
31 $WWW::Search::Test::sSaveOnError = q{enddate-failed.html};
32 # We need a query that returns "Featured Items" _and_ items that end
33 # in a few minutes. This one attracts Rock'n'Roll fans and
34 # philatelists:
35 TODO:
36 {
37 $TODO = 'We only need one page of results in order to test the end-date sort';
38 tm_run_test('normal', 'zeppelin', 45, 49, $iDebug, $iDump);
39 }
40 $TODO = '';
41 # goto ALL_DONE; # for debugging
42
43 # Now get some ByEndDate results and inspect them:
44 my @ao = $WWW::Search::Test::oSearch->results();
45 cmp_ok(0, '<', scalar(@ao), 'got some results');
46 my $sDatePrev = 'yesterday';
47 foreach my $oResult (@ao)
48 {
49 like($oResult->url, qr{\Ahttps?://(cgi|www)\d*\.ebay\.com},
50 'result URL really is from ebay.com');
51 my $sTitle = $oResult->title;
52 cmp_ok($sTitle, 'ne', '',
53 qq'result Title ($sTitle) is not empty');
54 like($oResult->description, qr{([0-9]+|no)\s+bids?},
55 'result bidcount is ok');
56 my $sDate = $oResult->end_date || '';
57 DEBUG_DATE && diag(qq{raw end date is '$sDate'});
58 diag(Dumper($oResult)) unless isnt($sDate, '', "end_date ($sDate) is not empty");
59 # It is not possible to test the order of results in this way,
60 # because eBay sometimes sticks paid (advertised) auctions at the
61 # top of the page (and those are not in order).
62 my $iCmp = Date_Cmp($sDatePrev, $sDate);
63 # cmp_ok($iCmp, '<=', 0, 'result is in order by end date');
64 $sDatePrev = $sDate;
65 } # foreach
66 pass('no-op');
67 ALL_DONE:
68 pass('no-op');
69
70 done_testing();
71
72 __END__
73