Mercurial > silorider
comparison tests/test_silos_twitter.py @ 18:a921cc2306bc
Do our own HTML parsing/stripping of micropost contents.
- This lets us properly handle various forms of linking.
- Add tests for processing posts with links.
- Fix configuration in tests.
- Basic error handling for processing posts.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 16 Sep 2018 21:16:20 -0700 |
parents | c199bd681e4e |
children | fb93d3fbff4e |
comparison
equal
deleted
inserted
replaced
17:678278cb85b1 | 18:a921cc2306bc |
---|---|
10 </div> | 10 </div> |
11 <a class="u-url" href="https://example.org/a-new-article">permalink</a>""" | 11 <a class="u-url" href="https://example.org/a-new-article">permalink</a>""" |
12 )) | 12 )) |
13 | 13 |
14 cli.appendSiloConfig('test', 'twitter', url='/blah') | 14 cli.appendSiloConfig('test', 'twitter', url='/blah') |
15 cli.setFeedConfig('feed', feed) | |
15 tweetmock.installTokens(cli, 'test') | 16 tweetmock.installTokens(cli, 'test') |
16 | 17 |
17 ctx, _ = cli.run('process', feed) | 18 ctx, _ = cli.run('process') |
18 assert ctx.cache.wasPosted('test', 'https://example.org/a-new-article') | 19 assert ctx.cache.wasPosted('test', 'https://example.org/a-new-article') |
19 toot = ctx.silos[0].client.tweets[0] | 20 toot = ctx.silos[0].client.tweets[0] |
20 assert toot == ('A new article https://example.org/a-new-article', []) | 21 assert toot == ('A new article https://example.org/a-new-article', []) |
21 | 22 |
22 | 23 |
25 """<p class="p-name">This is a quick update.</p> | 26 """<p class="p-name">This is a quick update.</p> |
26 <a class="u-url" href="/01234.html">permalink</a>""" | 27 <a class="u-url" href="/01234.html">permalink</a>""" |
27 )) | 28 )) |
28 | 29 |
29 cli.appendSiloConfig('test', 'twitter', url='/blah') | 30 cli.appendSiloConfig('test', 'twitter', url='/blah') |
31 cli.setFeedConfig('feed', feed) | |
30 tweetmock.installTokens(cli, 'test') | 32 tweetmock.installTokens(cli, 'test') |
31 | 33 |
32 ctx, _ = cli.run('process', feed) | 34 ctx, _ = cli.run('process') |
33 assert ctx.cache.wasPosted('test', '/01234.html') | 35 assert ctx.cache.wasPosted('test', '/01234.html') |
34 toot = ctx.silos[0].client.tweets[0] | 36 toot = ctx.silos[0].client.tweets[0] |
35 assert toot == ("This is a quick update.", []) | 37 assert toot == ("This is a quick update.", []) |
36 | 38 |
37 | 39 |
43 </div> | 45 </div> |
44 <a class="u-url" href="/01234.html">permalink</a>""" | 46 <a class="u-url" href="/01234.html">permalink</a>""" |
45 )) | 47 )) |
46 | 48 |
47 cli.appendSiloConfig('test', 'twitter', url='/blah') | 49 cli.appendSiloConfig('test', 'twitter', url='/blah') |
50 cli.setFeedConfig('feed', feed) | |
48 tweetmock.installTokens(cli, 'test') | 51 tweetmock.installTokens(cli, 'test') |
49 | 52 |
50 ctx, _ = cli.run('process', feed) | 53 ctx, _ = cli.run('process') |
51 | 54 |
52 assert ctx.cache.wasPosted('test', '/01234.html') | 55 assert ctx.cache.wasPosted('test', '/01234.html') |
53 toot = ctx.silos[0].client.tweets[0] | 56 toot = ctx.silos[0].client.tweets[0] |
54 assert toot == ("This is a quick photo update.", ['/fullimg.jpg']) | 57 assert toot == ("This is a quick photo update.", ['/fullimg.jpg']) |
55 | 58 |
63 </div> | 66 </div> |
64 <a class="u-url" href="/01234.html">permalink</a>""" | 67 <a class="u-url" href="/01234.html">permalink</a>""" |
65 )) | 68 )) |
66 | 69 |
67 cli.appendSiloConfig('test', 'twitter', url='/blah') | 70 cli.appendSiloConfig('test', 'twitter', url='/blah') |
71 cli.setFeedConfig('feed', feed) | |
68 tweetmock.installTokens(cli, 'test') | 72 tweetmock.installTokens(cli, 'test') |
69 | 73 |
70 ctx, _ = cli.run('process', feed) | 74 ctx, _ = cli.run('process') |
71 | 75 |
72 assert ctx.cache.wasPosted('test', '/01234.html') | 76 assert ctx.cache.wasPosted('test', '/01234.html') |
73 toot = ctx.silos[0].client.tweets[0] | 77 toot = ctx.silos[0].client.tweets[0] |
74 assert toot == ("This is a photo update with 2 photos.", | 78 assert toot == ("This is a photo update with 2 photos.", |
75 ['/fullimg1.jpg', '/fullimg2.jpg']) | 79 ['/fullimg1.jpg', '/fullimg2.jpg']) |