Mercurial > silorider
annotate tests/test_commands_populate.py @ 63:c4dbbbb4990a
Fix Bluesky unit tests
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Sat, 28 Oct 2023 13:06:45 -0700 |
| parents | 91dea4fe31ec |
| children |
| rev | line source |
|---|---|
| 0 | 1 |
| 2 feed1 = """ | |
|
61
91dea4fe31ec
Fix another unit test to be more explicit about where the feed is.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
3 <html><body class="h-feed"> |
| 0 | 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): | |
|
18
a921cc2306bc
Do our own HTML parsing/stripping of micropost contents.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
16 feed = cli.createTempFeed(feed1) |
| 0 | 17 cli.appendSiloConfig('test', 'print', items='name') |
|
18
a921cc2306bc
Do our own HTML parsing/stripping of micropost contents.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
18 cli.setFeedConfig('feed', feed) |
|
a921cc2306bc
Do our own HTML parsing/stripping of micropost contents.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
19 ctx, _ = cli.run('populate', '-s', 'test') |
| 0 | 20 assert ctx.cache.wasPosted('test', 'https://example.org/a-new-article') |
| 21 | |
| 22 | |
| 23 feed2 = """ | |
|
61
91dea4fe31ec
Fix another unit test to be more explicit about where the feed is.
Ludovic Chabant <ludovic@chabant.com>
parents:
41
diff
changeset
|
24 <html><body class="h-feed"> |
| 0 | 25 <article class="h-entry"> |
| 26 <h1 class="p-name">First article</h1> | |
| 27 <div><time class="dt-published" datetime="2018-01-07T09:30:00-00:00"></time></div> | |
| 28 <a class="u-url" href="https://example.org/first-article">permalink</a> | |
| 29 </article> | |
| 30 <article class="h-entry"> | |
| 31 <h1 class="p-name">Second article</h1> | |
| 32 <div><time class="dt-published" datetime="2018-01-08T09:30:00-00:00"></time></div> | |
| 33 <a class="u-url" href="https://example.org/second-article">permalink</a> | |
| 34 </article> | |
| 35 <article class="h-entry"> | |
| 36 <h1 class="p-name">Third article</h1> | |
| 37 <div><time class="dt-published" datetime="2018-01-09T09:30:00-00:00"></time></div> | |
| 38 <a class="u-url" href="https://example.org/third-article">permalink</a> | |
| 39 </article> | |
| 40 </body></html>""" # NOQA | |
| 41 | |
| 42 | |
| 43 def test_populate_until(cli): | |
|
18
a921cc2306bc
Do our own HTML parsing/stripping of micropost contents.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
44 feed = cli.createTempFeed(feed2) |
| 0 | 45 cli.appendSiloConfig('test', 'print', items='name') |
|
18
a921cc2306bc
Do our own HTML parsing/stripping of micropost contents.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
46 cli.setFeedConfig('feed', feed) |
|
41
1db1890edcf5
Change populate command's 'until' argument to be exclusive and support time
Ludovic Chabant <ludovic@chabant.com>
parents:
18
diff
changeset
|
47 ctx, _ = cli.run('populate', '-s', 'test', '--until', '2018-01-08 9AM') |
| 0 | 48 assert ctx.cache.wasPosted('test', 'https://example.org/first-article') |
| 49 assert ctx.cache.wasPosted('test', 'https://example.org/second-article') | |
| 50 assert not ctx.cache.wasPosted('test', 'https://example.org/third-article') |
