File: 001_load.t

package info (click to toggle)
libxml-rss-feed-perl 2.212-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 312 kB
  • sloc: perl: 2,581; makefile: 2
file content (141 lines) | stat: -rwxr-xr-x 3,532 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 27;

BEGIN {
    use_ok('XML::RSS::Feed');
    use_ok('XML::RSS::Headline');
    use_ok('Time::HiRes');
}

$SIG{__WARN__} = build_warn("Invalid argument");
isa_ok(
    XML::RSS::Feed->new(
        url     => "http://www.jbisbee.com/rdf/",
        name    => 'jbisbee',
        delay   => 7200,
        bad_arg => 1,
        debug   => 1,
    ),
    "XML::RSS::Feed"
);

$SIG{__WARN__} = build_warn("No cache file found");
isa_ok(
    XML::RSS::Feed->new(
        title  => "This is a fake RSS Title",
        name   => 'jbisbee_test',
        url    => "http://www.jbisbee.com/rsstest",
        tmpdir => 'pretend_tmpdir',
        debug  => 1,
    ),
    "XML::RSS::Feed"
);

isa_ok(
    XML::RSS::Headline->new(
        url      => "http://www.jbisbee.com/testurl/1",
        headline => "Test Headline",
    ),
    "XML::RSS::Headline"
);

isa_ok(
    XML::RSS::Headline->new(
        url         => "http://www.jbisbee.com/testurl/1",
        description => "Test Headline",
    ),
    "XML::RSS::Headline"
);

$SIG{__WARN__} = build_warn("Failed to set headline");
ok( !XML::RSS::Headline->new(
        url         => "http://www.jbisbee.com/testurl/1",
        description => ".",
    ),
    "Bad description"
);

isa_ok(
    XML::RSS::Headline->new(
        url         => "http://www.jbisbee.com/testurl/1",
        headline    => "Test Headline",
        description => "Test Description",
    ),
    'XML::RSS::Headline',
    'via url/headline/description'
);

isa_ok(
    XML::RSS::Headline->new(
        url        => "http://www.jbisbee.com/testurl/1",
        headline   => "Test Headline",
        first_seen => Time::HiRes::time(),
    ),
    'XML::RSS::Headline',
    'set first_seen'
);

isa_ok(
    XML::RSS::Headline->new(
        item => {
            link  => "http://www.jbisbee.com/testurl/1",
            title => "Test Headline",
        },
    ),
    'XML::RSS::Headline',
    'via $args{item} - link/title'
);

isa_ok(
    XML::RSS::Headline->new(
        item => {
            link        => "http://www.jbisbee.com/testurl/1",
            title       => "Test Headline",
            description => "Test Description",
        },
    ),
    'XML::RSS::Headline',
    'via $args{item} - link/title/description'
);

$SIG{__WARN__} = build_warn("Invalid argument");
isa_ok(
    XML::RSS::Headline->new(
        url         => "http://www.jbisbee.com/testurl/1",
        headline    => "Test Headline",
        description => "Test Description",
        bad_arg     => "bad argument"
    ),
    "XML::RSS::Headline"
);

$SIG{__WARN__}
    = build_warn("item must contain either title/link or description/link");
ok( !XML::RSS::Headline->new(
        item => {
            title       => "Test Headline",
            description => "Test Description"
        }
    ),
    "Failed to instantiate"
);

$SIG{__WARN__}
    = build_warn("item must contain either title/link or description/link");
ok( !XML::RSS::Headline->new( item => { fake => 1 } ),
    "Failed to instantiate" );

$SIG{__WARN__} = build_warn(
    "Either item, url/headline. or url/description are required");
ok( !XML::RSS::Headline->new, "Failed to instantiate" );
ok( !XML::RSS::Headline->new( headline => "Test Headline" ),
    "Failed to instantiate" );
ok( !XML::RSS::Headline->new( url => "http://www.jbisbee.com/testurl/1" ),
    "Failed to instantiate" );

sub build_warn {
    my @args = @_;
    return sub { my ($warn) = @_; like( $warn, qr/$_/i, $_ ) for @args };
}