-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-plugins
More file actions
executable file
·477 lines (449 loc) · 13.5 KB
/
test-plugins
File metadata and controls
executable file
·477 lines (449 loc) · 13.5 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#!/bin/sh
# test-plugins: run tests on rawdog's plugins
# Copyright 2013 Adam Sampson <ats@offog.org>
#
# rawdog is free software; you can redistribute and/or modify it
# under the terms of that license as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# rawdog is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with rawdog; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA, or see http://www.gnu.org/.
# (This script should be called from test-rawdog, rather than run on its own.)
plugin () {
cp rawdog-plugins/"$1" $statedir/plugins
}
# FIXME archive.py
begin "article-filter plugin"
plugin article-filter.py
cat >$httpdir/feed.rss <<EOF
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Variably Dull Feed</title>
<link>http://example.org/</link>
<description>example-feed-description</description>
<item>
<title>Cats are awesome</title>
<dc:creator>Cory</dc:creator>
<link>http://example.org/item1</link>
</item>
<item>
<title>Cars are awesome</title>
<dc:creator>Xeni</dc:creator>
<link>http://example.org/item2</link>
</item>
<item>
<title>Fish are awesome</title>
<dc:creator>Mark</dc:creator>
<link>http://example.org/item3</link>
</item>
<item>
<title>Robots are awesome</title>
<dc:creator>Cory</dc:creator>
<link>http://example.org/item4</link>
</item>
</channel>
</rss>
EOF
add "feed 0 $httpurl/feed.rss"
add ' filter hide author "^Xeni" ; hide author "^Cory" ; show author "^Cory" title "(?i)robot"'
runs -uw
contains $statedir/output.html Fish Robots
not_contains $statedir/output.html Cats Cars
add ' filter hide ; show author "^Mark"'
runs -w
contains $statedir/output.html Fish
not_contains $statedir/output.html Robots Cats Cars
begin "article-stats plugin"
plugin article-stats.py
add "expireage 0"
add "keepmin 1"
add "feed 0 $httpurl/feed.rss"
make_range 1 5 $httpdir/feed.rss
run -uw
# added, updated, expired, total
equals "5 0 0 5" "$(cat $outfile)"
make_range 1 10 $httpdir/feed.rss
run -uw
equals "5 5 0 10" "$(cat $outfile)"
make_range 6 10 $httpdir/feed.rss
run -uw
equals "0 5 5 5" "$(cat $outfile)"
begin "author-no-link plugin"
plugin author-no-link.py
cat >$httpdir/feed.atom <<EOF
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>example-feed-title</title>
<link href="http://example.org/"/>
<updated>2013-01-01T18:00:00Z</updated>
<id>http://example.org/feed-id</id>
<entry>
<author>
<name>Author</name>
<email>author@example.org</email>
</author>
<title>example-item-title</title>
<link href="http://example.org/item"/>
<id>http://example.org/item-id</id>
<updated>2013-01-01T18:00:00Z</updated>
<summary>example-item-description</summary>
</entry>
</feed>
EOF
echo "in<__author__> out<__author_no_link__>" >$statedir/item
add "feed 0 $httpurl/feed.atom"
add "itemtemplate item"
runs -uw
not_contains $statedir/output.html "in<Author>"
contains $statedir/output.html "out<Author>"
begin "backwards plugin"
make_n 3 $httpdir/feed.rss
add "feed 0 $httpurl/feed.rss"
runs -uw
grep range-title $statedir/output.html >$statedir/before
plugin backwards.py
runs -w
grep range-title $statedir/output.html | perl -e 'print join("", reverse(<>))' >$statedir/after
same $statedir/before $statedir/after
# FIXME dated-output.py
begin "detwit plugin"
plugin detwit.py
cat >$httpdir/feed.rss <<EOF
<rss version="2.0">
<channel>
<title>Oddly Prefixed Feed</title>
<link>http://example.org/</link>
<description>example-feed-description</description>
<item>
<title>junk: actual content</title>
<link>http://example.org/item1</link>
</item>
</channel>
</rss>
EOF
add "feed 0 $httpurl/feed.rss"
add " detwit true"
runs -uw
contains $statedir/output.html "actual content"
not_contains $statedir/output.html "junk"
begin "digest-auth plugin"
plugin digest-auth.py
make_atom10 $httpdir/secret.atom
add "feed 0 $httpurl/digest-hello-world/secret.atom"
add " user hello"
add " password world"
runs -uw
contains $statedir/output.html example-item-title
if wget --version >/dev/null 2>&1; then
begin "download-articles plugin"
plugin download-articles.py
make_html $httpdir/page.html
cat >$httpdir/feed.rss <<EOF
<rss version="2.0">
<channel>
<title>example-feed</title>
<link>http://example.org/</link>
<description>example-feed-description</description>
<item>
<title>item-title</title>
<link>$httpurl/page.html</link>
</item>
</channel>
</rss>
EOF
run -s item
cp $outfile $statedir/item
echo "localcopy<__localcopy__>" >>$statedir/item
add "itemtemplate item"
add "feed 0 $httpurl/feed.rss"
loc=$(echo $httpurl/page.html | sed 's,^http:/,local-cache,')
for i in 1 2; do
runs -uw
contains $statedir/output.html "localcopy<$loc>"
same $statedir/$loc $httpdir/page.html
done
else
begin "download-articles plugin (skipped; no wget)"
fi
begin "enclosure plugin"
plugin enclosure.py
cat >$httpdir/feed.rss <<EOF
<rss version="2.0">
<channel>
<title>example-feed</title>
<link>http://example.org/</link>
<description>example-feed-description</description>
<item>
<title>item-title-1</title>
<link>$httpurl/1</link>
<enclosure url="$httpurl/podcast.mp3" length="123456" type="audio/mpeg" />
</item>
<item>
<title>item-title</title>
<link>$httpurl/2</link>
<!-- Check that special chars get encoded properly -->
<enclosure url="$httpurl/script?a=x&amp=y" length="7890" type="audio/mpeg" />
</item>
</channel>
</rss>
EOF
cat >$statedir/item <<EOF
href(__enclosure-href__)
length(__enclosure-length__)
type(__enclosure-type__)
EOF
add "feed 0 $httpurl/feed.rss"
add "itemtemplate item"
runs -uw
contains $statedir/output.html \
"href($httpurl/podcast.mp3)" \
"length(123456)" \
"type(audio/mpeg)" \
"href($httpurl/script?a=x&amp=y"
begin "feed-execute plugin"
plugin feed-execute.py
make_atom10 $httpdir/0.atom
dir=$(cd $httpdir && pwd)
add "feed 0 $httpurl/1.atom"
add " pre-execute mv $dir/0.atom $dir/1.atom"
add " post-execute mv $dir/1.atom $dir/0.atom"
runs -uw
contains $statedir/output.html example-item-title
exists $httpdir/0.atom
# FIXME feedgrep.py
# FIXME feedgroup.py
# FIXME feedwise-ca.py
# FIXME feedwise-ig.py
# FIXME feedwise.py
# FIXME imgstrip.py
# FIXME inline_link.py
begin "links plugin"
plugin links.py
add "link http://example.org/ First"
add "link http://example.org/foo?a=x&=y Second"
run -s page
cp $outfile $statedir/page
echo __links__ >>$statedir/page
add "pagetemplate page"
runs -uw
contains $statedir/output.html \
'<a href="http://example.org/">First</a>' \
'<a href="http://example.org/foo?a=x&amp=y">Second</a>'
# FIXME ljkludge.py
begin "paged-output plugin"
plugin paged-output.py
make_n 40 $httpdir/feed.rss
add "feed 0 $httpurl/feed.rss"
add "articlesperpage 10"
run -s page
cp $outfile $statedir/page
echo __paged_output_head__ >>$statedir/page
add "pagetemplate page"
runs -uw
contains $statedir/output.html $(range 1 10) \
'rel="prev" href="output1.html"'
not_contains $statedir/output.html $(range 11 40) \
'rel="next"'
contains $statedir/output1.html $(range 11 20) \
'rel="next" href="output.html"' \
'rel="prev" href="output2.html"'
contains $statedir/output2.html $(range 21 30)
contains $statedir/output3.html $(range 31 40)
not_contains $statedir/output3.html 'rel="prev"'
# FIXME printnew.py
# FIXME rss.py
begin "select-feeds plugin"
plugin select-feeds.py
make_single $httpdir/0.atom item-a http://example.org/a http://example.org/0
make_single $httpdir/1.atom item-b http://example.org/b http://example.org/1
make_single $httpdir/2.atom item-c http://example.org/c http://example.org/2
add "feed 0 $httpurl/0.atom"
add "feed 0 $httpurl/1.atom"
add "feed 0 $httpurl/2.atom"
runs -uw
contains $statedir/output.html item-a item-b item-c
add "selectfeeds $httpurl/0.atom"
runs -w
contains $statedir/output.html item-a
not_contains $statedir/output.html item-b item-c
add "selectfeeds $httpurl/1.atom"
runs -w
contains $statedir/output.html item-a item-b
not_contains $statedir/output.html item-c
# FIXME sidebarfeedwise-0.1.tar.gz
begin "since-last plugin"
plugin since-last.py
add "feed 0 $httpurl/feed.rss"
make_range 1 5 $httpdir/feed.rss
runs -uw
output_range 1 5
runs -w
not_output_range 1 5
make_range 6 10 $httpdir/feed.rss
runs -uw
output_range 6 10
not_output_range 1 5
make_range 11 15 $httpdir/feed.rss
runs -uw
output_range 11 15
not_output_range 1 10
# Generate an RSS2 feed with Slashdot's extensions.
make_slashdot () {
cat >"$1" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/">
<channel>
<title>Not Slashdot</title>
<link>http://example.org/</link>
<description>Description</description>
<item>
<title>item-title-1</title>
<link>http://example.org/item1</link>
<description>description-1</description>
<pubDate>Fri, 02 Aug 2013 09:27:00 GMT</pubDate>
<guid isPermaLink="false">http://not.example.org/1234567-1</guid>
<dc:creator>pseudonym</dc:creator>
<dc:subject>rawdog</dc:subject>
<dc:date>2013-01-01T18:00:00Z</dc:date>
<slash:comments>42</slash:comments>
<slash:department>testing-the-parser</slash:department>
<slash:section>news</slash:section>
<slash:hit_parade>1,2,3,4,5,6,7</slash:hit_parade>
<feedburner:origLink>http://example.org/orig/item1</feedburner:origLink>
</item>
<item>
<title>item-title-2</title>
<link>http://example.org/item2</link>
<description>description-2</description>
<guid isPermaLink="false">http://not.example.org/1234567-2</guid>
<slash:section>x<y</slash:section>
<slash:department>entities-&-text</slash:department>
</item>
</channel>
</rss>
EOF
}
begin "slashdot-bam plugin"
plugin slashdot-bam.py
make_slashdot $httpdir/feed.rss
add "feed 0 $httpurl/feed.rss"
runs -uw
contains $statedir/output.html \
"from the testing-the-parser dept." \
"from the entities-&-text dept."
begin "slashdot plugin"
plugin slashdot.py
make_slashdot $httpdir/feed.rss
add "feed 0 $httpurl/feed.rss"
cat >$statedir/item <<EOF
section(__slash-section__)
dept(__slash-department__)
EOF
add "itemtemplate item"
runs -uw
contains $statedir/output.html \
"section(news)" \
"dept(testing-the-parser)" \
"section(x<y)" \
"dept(entities-&-text)"
begin "status-log plugin"
plugin status-log.py
make_atom10 $httpdir/feed.atom
add "feed 0 $httpurl/feed.atom"
runs -uw
contains $statedir/status-log ok-200
exists $statedir/status-log $statedir/status-log.html
add "statuslogfile log"
add "statusoutputfile log.html"
runs -uw
exists $statedir/log $statedir/log.html
contains $statedir/log ok-304
contains $statedir/log.html "rawdog feed status"
add "feed 0 $httpurl/302/feed.atom"
run -uw
contains $statedir/log redirect-302
add "feed 0 $httpurl/301/feed.atom"
run -uw
contains $statedir/log redirect-301
add "feed 0 $httpurl/nothere.atom"
run -uw
contains $statedir/log error-404
add "timeout 1s"
add "feed 0 http://$serverhost:$timeoutport/timeout.atom"
run -uw
contains $statedir/log error-timeout
contains $statedir/log.html "TO"
begin "truncate plugin"
plugin truncate.py
cat >$httpdir/feed.rss <<EOF
<rss version="2.0">
<channel>
<title>Variably Long Feed</title>
<link>http://example.org/</link>
<description>example-feed-description</description>
<item>
<title>A</title>
<link>http://example.org/item1</link>
<description>AA23456789012345678901234567890</description>
</item>
<item>
<title>B</title>
<link>http://example.org/item2</link>
<description>BB2345678<b>90123456789</description>
</item>
<item>
<title>C</title>
<link>http://example.org/item3</link>
<description>CC23456<b></description>
</item>
<item>
<title>D</title>
<link>http://example.org/item4</link>
<description>DD23456789</description>
</item>
<item>
<title>E</title>
<link>http://example.org/item4</link>
<description><b>xy</b></description>
</item>
</channel>
</rss>
EOF
echo "(__description__)" >>$statedir/item
add "tidyhtml false"
add "blocklevelhtml false"
add "itemtemplate item"
add "feed 0 $httpurl/feed.rss"
add " truncate 10"
runs -uw
contains $statedir/output.html \
"(AA23456789...)" "(BB2345678...)" "(CC23456<b>)" "(DD23456789)" \
"(<b>xy</b>)"
add " killtags true"
rm $statedir/state
runs -uw
contains $statedir/output.html \
"(AA23456789...)" "(BB2345678...)" "(CC23456)" "(DD23456789)" \
"(xy)"
begin "vellum-templates plugin"
plugin vellum-templates.py
cat >$statedir/page <<EOF
I have <%= num_feeds %> feeds
<% for num in range(3): %>
Hello-<%= num %>
<% end %>
EOF
add "template page"
runs -uw
contains $statedir/output.html \
"I have 0 feeds" \
"Hello-0" "Hello-1" "Hello-2"
# FIXME xml_archiver.py