Mercurial > silorider
comparison tests/test_commands_populate.py @ 0:a1b7a459326a
Initial commit.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 18 Jul 2018 20:46:04 -0700 |
parents | |
children | a921cc2306bc |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a1b7a459326a |
---|---|
1 | |
2 feed1 = """ | |
3 <html><body> | |
4 <article class="h-entry"> | |
5 <h1 class="p-name">A new article</h1> | |
6 <div class="e-content"> | |
7 <p>This is the text of the article.</p> | |
8 <p>It has 2 paragraphs.</p> | |
9 </div> | |
10 <a class="u-url" href="https://example.org/a-new-article">permalink</a> | |
11 </article> | |
12 </body></html>""" | |
13 | |
14 | |
15 def test_populate(cli): | |
16 cli.appendSiloConfig('test', 'print', items='name') | |
17 feed = cli.createTempFeed(feed1) | |
18 ctx, _ = cli.run('populate', feed, '-s', 'test') | |
19 assert ctx.cache.wasPosted('test', 'https://example.org/a-new-article') | |
20 | |
21 | |
22 feed2 = """ | |
23 <html><body> | |
24 <article class="h-entry"> | |
25 <h1 class="p-name">First article</h1> | |
26 <div><time class="dt-published" datetime="2018-01-07T09:30:00-00:00"></time></div> | |
27 <a class="u-url" href="https://example.org/first-article">permalink</a> | |
28 </article> | |
29 <article class="h-entry"> | |
30 <h1 class="p-name">Second article</h1> | |
31 <div><time class="dt-published" datetime="2018-01-08T09:30:00-00:00"></time></div> | |
32 <a class="u-url" href="https://example.org/second-article">permalink</a> | |
33 </article> | |
34 <article class="h-entry"> | |
35 <h1 class="p-name">Third article</h1> | |
36 <div><time class="dt-published" datetime="2018-01-09T09:30:00-00:00"></time></div> | |
37 <a class="u-url" href="https://example.org/third-article">permalink</a> | |
38 </article> | |
39 </body></html>""" # NOQA | |
40 | |
41 | |
42 def test_populate_until(cli): | |
43 cli.appendSiloConfig('test', 'print', items='name') | |
44 feed = cli.createTempFeed(feed2) | |
45 ctx, _ = cli.run('populate', feed, '-s', 'test', '--until', '2018-01-08') | |
46 assert ctx.cache.wasPosted('test', 'https://example.org/first-article') | |
47 assert ctx.cache.wasPosted('test', 'https://example.org/second-article') | |
48 assert not ctx.cache.wasPosted('test', 'https://example.org/third-article') |