summaryrefslogtreecommitdiff
path: root/tests/unit/engines/test_twitter.py
blob: b444b48eeec1fc9be624995191820cfa24c11171 (plain)
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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# -*- coding: utf-8 -*-
from collections import defaultdict
import mock
from searx.engines import twitter
from searx.testing import SearxTestCase


class TestTwitterEngine(SearxTestCase):

    def test_request(self):
        query = 'test_query'
        dicto = defaultdict(dict)
        dicto['pageno'] = 0
        dicto['language'] = 'fr_FR'
        params = twitter.request(query, dicto)
        self.assertIn('url', params)
        self.assertIn(query, params['url'])
        self.assertIn('twitter.com', params['url'])
        self.assertIn('cookies', params)
        self.assertIn('lang', params['cookies'])
        self.assertIn('fr', params['cookies']['lang'])

        dicto['language'] = 'all'
        params = twitter.request(query, dicto)
        self.assertIn('cookies', params)
        self.assertIn('lang', params['cookies'])
        self.assertIn('en', params['cookies']['lang'])

    def test_response(self):
        self.assertRaises(AttributeError, twitter.response, None)
        self.assertRaises(AttributeError, twitter.response, [])
        self.assertRaises(AttributeError, twitter.response, '')
        self.assertRaises(AttributeError, twitter.response, '[]')

        response = mock.Mock(text='<html></html>')
        self.assertEqual(twitter.response(response), [])

        html = """
        <li class="js-stream-item stream-item stream-item expanding-stream-item" data-item-id="563005573290287105"
            id="stream-item-tweet-563005573290287105" data-item-type="tweet">
            <div class="tweet original-tweet js-stream-tweet js-actionable-tweet js-profile-popup-actionable
                js-original-tweet has-cards has-native-media" data-tweet-id="563005573290287105" data-disclosure-type=""
                data-item-id="563005573290287105" data-screen-name="Jalopnik" data-name="Jalopnik"
                data-user-id="3060631" data-has-native-media="true" data-has-cards="true" data-card-type="photo"
                data-expanded-footer="&lt;div class=&quot;js-tweet-details-fixer
                tweet-details-fixer&quot;&gt;&#10;&#10;&#10;
                &lt;div class=&quot;cards-media-container js-media-container&quot;&gt;&lt;div
                data-card-url=&quot;//twitter.com/Jalopnik/status/563005573290287105/photo/1&quot; data-card-type=&quot;
                photo&quot; class=&quot;cards-base cards-multimedia&quot; data-element-context=&quot;platform_photo_card
                &quot;&gt;&#10;&#10;&#10;  &lt;a class=&quot;media media-thumbnail twitter-timeline-link is-preview
                &quot; data-url=&quot;https://pbs.twimg.com/media/B9Aylf5IMAAuziP.jpg:large&quot;
                data-resolved-url-large=&quot;https://pbs.twimg.com/media/B9Aylf5IMAAuziP.jpg:large&quot;
                href=&quot;//twitter.com/Jalopnik/status/563005573290287105/photo/1&quot;&gt;&#10;
                &lt;div class=&quot;&quot;&gt;&#10; &lt;img src=&quot;
                https://pbs.twimg.com/media/B9Aylf5IMAAuziP.jpg&quot;
                alt=&quot;Embedded image permalink&quot; width=&quot;636&quot; height=&quot;309&quot;&gt;&#10;
                &lt;/div&gt;&#10;&#10;  &lt;/a&gt;&#10;&#10;  &lt;div class=&quot;cards-content&quot;&gt;&#10;
                &lt;div class=&quot;byline&quot;&gt;&#10;      &#10;    &lt;/div&gt;&#10;    &#10;  &lt;/div&gt;&#10;
                &#10;&lt;/div&gt;&#10;&#10;&#10;&#10;&#10;&lt;/div&gt;&#10;&#10;&#10;&#10;  &lt;div
                class=&quot;js-machine-translated-tweet-container&quot;&gt;&lt;/div&gt;&#10;    &lt;div
                class=&quot;js-tweet-stats-container tweet-stats-container &quot;&gt;&#10;    &lt;/div&gt;&#10;&#10;
                &lt;div class=&quot;client-and-actions&quot;&gt;&#10;  &lt;span class=&quot;metadata&quot;&gt;&#10;
                &lt;span&gt;5:06 PM - 4 Feb 2015&lt;/span&gt;&#10;&#10;       &amp;middot; &lt;a
                class=&quot;permalink-link js-permalink js-nav&quot; href=&quot;/Jalopnik/status/563005573290287105
                &quot;tabindex=&quot;-1&quot;&gt;Details&lt;/a&gt;&#10;    &#10;&#10;        &#10;        &#10;
                &#10;&#10;  &lt;/span&gt;&#10;&lt;/div&gt;&#10;&#10;&#10;&lt;/div&gt;&#10;" data-you-follow="false"
                data-you-block="false">
                <div class="context">
                </div>
                <div class="content">
                    <div class="stream-item-header">
                        <a class="account-group js-account-group js-action-profile js-user-profile-link js-nav"
                            href="/Jalopnik" data-user-id="3060631">
                            <img class="avatar js-action-profile-avatar"
                                src="https://pbs.twimg.com/profile_images/2976430168/5cd4a59_bigger.jpeg" alt="">
                            <strong class="fullname js-action-profile-name show-popup-with-id" data-aria-label-part>
                                Jalopnik
                            </strong>
                            <span>&rlm;</span>
                            <span class="username js-action-profile-name" data-aria-label-part>
                            <s>@</s><b>TitleName</b>
                            </span>
                        </a>
                        <small class="time">
                        <a href="/this.is.the.url"
                            class="tweet-timestamp js-permalink js-nav js-tooltip" title="5:06 PM - 4 Feb 2015" >
                            <span class="u-hiddenVisually" data-aria-label-part="last">17 minutes ago</span>
                        </a>
                        </small>
                    </div>
                    <p class="js-tweet-text tweet-text" lang="en" data-aria-label-part="0">
                        This is the content étude à€
                        <a href="http://t.co/nRWsqQAwBL" rel="nofollow" dir="ltr"
                            data-expanded-url="http://jalo.ps/ReMENu4" class="twitter-timeline-link"
                            target="_blank" title="http://jalo.ps/ReMENu4" >
                        <span class="tco-ellipsis">
                        </span>
                        <span class="invisible">http://</span><span class="js-display-url">link.in.tweet</span>
                        <span class="invisible"></span>
                        <span class="tco-ellipsis">
                            <span class="invisible">&nbsp;</span>
                        </span>
                    </a>
                    <a href="http://t.co/rbFsfeE0l3" class="twitter-timeline-link u-hidden"
                        data-pre-embedded="true" dir="ltr">
                        pic.twitter.com/rbFsfeE0l3
                    </a>
                    </p>
                    <div class="expanded-content js-tweet-details-dropdown">
                    </div>
                    <div class="stream-item-footer">
                        <a class="details with-icn js-details" href="/Jalopnik/status/563005573290287105">
                            <span class="Icon Icon--photo">
                            </span>
                            <b>
                                <span class="expand-stream-item js-view-details">
                                    View photo
                                </span>
                                <span class="collapse-stream-item  js-hide-details">
                                    Hide photo
                                </span>
                            </b>
                        </a>
                        <span class="ProfileTweet-action--reply u-hiddenVisually">
                            <span class="ProfileTweet-actionCount" aria-hidden="true" data-tweet-stat-count="0">
                                <span class="ProfileTweet-actionCountForAria" >0 replies</span>
                            </span>
                        </span>
                        <span class="ProfileTweet-action--retweet u-hiddenVisually">
                            <span class="ProfileTweet-actionCount"  data-tweet-stat-count="8">
                                <span class="ProfileTweet-actionCountForAria" data-aria-label-part>8 retweets</span>
                            </span>
                        </span>
                        <span class="ProfileTweet-action--favorite u-hiddenVisually">
                            <span class="ProfileTweet-actionCount"  data-tweet-stat-count="14">
                                <span class="ProfileTweet-actionCountForAria" data-aria-label-part>14 favorites</span>
                            </span>
                        </span>
                        <div role="group" aria-label="Tweet actions" class="ProfileTweet-actionList u-cf js-actions">
                            <div class="ProfileTweet-action ProfileTweet-action--reply">
                                <button class="ProfileTweet-actionButton u-textUserColorHover js-actionButton
                                    js-actionReply" data-modal="ProfileTweet-reply" type="button" title="Reply">
                                    <span class="Icon Icon--reply">
                                    </span>
                                    <span class="u-hiddenVisually">Reply</span>
                                    <span class="ProfileTweet-actionCount u-textUserColorHover
                                        ProfileTweet-actionCount--isZero">
                                        <span class="ProfileTweet-actionCountForPresentation" aria-hidden="true">
                                        </span>
                                    </span>
                                </button>
                            </div>
                            <div class="ProfileTweet-action ProfileTweet-action--retweet js-toggleState js-toggleRt">
                                <button class="ProfileTweet-actionButton  js-actionButton js-actionRetweet js-tooltip"
                                    title="Retweet" data-modal="ProfileTweet-retweet" type="button">
                                    <span class="Icon Icon--retweet">
                                    </span>
                                    <span class="u-hiddenVisually">Retweet</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">8</span>
                                    </span>
                                </button>
                                <button class="ProfileTweet-actionButtonUndo js-actionButton js-actionRetweet"
                                    data-modal="ProfileTweet-retweet" title="Undo retweet" type="button">
                                    <span class="Icon Icon--retweet">
                                    </span>
                                    <span class="u-hiddenVisually">Retweeted</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">8</span>
                                    </span>
                                </button>
                            </div>
                            <div class="ProfileTweet-action ProfileTweet-action--favorite js-toggleState">
                                <button class="ProfileTweet-actionButton js-actionButton js-actionFavorite js-tooltip"
                                    title="Favorite" type="button">
                                    <span class="Icon Icon--favorite">
                                    </span>
                                    <span class="u-hiddenVisually">Favorite</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">14</span>
                                    </span>
                                </button>
                                <button class="ProfileTweet-actionButtonUndo u-linkClean js-actionButton
                                    js-actionFavorite" title="Undo favorite" type="button">
                                    <span class="Icon Icon--favorite">
                                    </span>
                                    <span class="u-hiddenVisually">Favorited</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">
                                            14
                                        </span>
                                    </span>
                                </button>
                            </div>
                            <div class="ProfileTweet-action ProfileTweet-action--more js-more-ProfileTweet-actions">
                                <div class="dropdown">
                                    <button class="ProfileTweet-actionButton u-textUserColorHover dropdown-toggle
                                        js-tooltip js-dropdown-toggle" type="button" title="More">
                                        <span class="Icon Icon--dots">
                                        </span>
                                        <span class="u-hiddenVisually">More</span>
                                    </button>
                                    <div class="dropdown-menu">
                                        <div class="dropdown-caret">
                                            <div class="caret-outer">
                                            </div>
                                            <div class="caret-inner">
                                            </div>
                                        </div>
                                        <ul>
                                            <li class="share-via-dm js-actionShareViaDM" data-nav="share_tweet_dm">
                                                <button type="button" class="dropdown-link">
                                                    Share via Direct Message
                                                </button>
                                            </li>
                                            <li class="embed-link js-actionEmbedTweet" data-nav="embed_tweet">
                                                <button type="button" class="dropdown-link">
                                                    Embed Tweet
                                                </button>
                                            </li>
                                            <li class="mute-user-item pretty-link">
                                                <button type="button" class="dropdown-link">
                                                    Mute
                                                </button>
                                            </li>
                                            <li class="unmute-user-item pretty-link">
                                                <button type="button" class="dropdown-link">
                                                    Unmute
                                                </button>
                                            </li>
                                            <li class="block-or-report-link js-actionBlockOrReport"
                                                data-nav="block_or_report">
                                                <button type="button" class="dropdown-link">
                                                    Block or report
                                                </button>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </li>
        """
        response = mock.Mock(text=html)
        results = twitter.response(response)
        self.assertEqual(type(results), list)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['title'], '@TitleName')
        self.assertEqual(results[0]['url'], 'https://twitter.com/this.is.the.url')
        self.assertIn(u'This is the content', results[0]['content'])
        # self.assertIn(u'This is the content étude à€', results[0]['content'])

        html = """
        <li class="js-stream-item stream-item stream-item expanding-stream-item" data-item-id="563005573290287105"
            id="stream-item-tweet-563005573290287105" data-item-type="tweet">
            <div class="tweet original-tweet js-stream-tweet js-actionable-tweet js-profile-popup-actionable
                js-original-tweet has-cards has-native-media" data-tweet-id="563005573290287105" data-disclosure-type=""
                data-item-id="563005573290287105" data-screen-name="Jalopnik" data-name="Jalopnik"
                data-user-id="3060631" data-has-native-media="true" data-has-cards="true" data-card-type="photo"
                data-expanded-footer="&lt;div class=&quot;js-tweet-details-fixer
                tweet-details-fixer&quot;&gt;&#10;&#10;&#10;
                &lt;div class=&quot;cards-media-container js-media-container&quot;&gt;&lt;div
                data-card-url=&quot;//twitter.com/Jalopnik/status/563005573290287105/photo/1&quot; data-card-type=&quot;
                photo&quot; class=&quot;cards-base cards-multimedia&quot; data-element-context=&quot;platform_photo_card
                &quot;&gt;&#10;&#10;&#10;  &lt;a class=&quot;media media-thumbnail twitter-timeline-link is-preview
                &quot; data-url=&quot;https://pbs.twimg.com/media/B9Aylf5IMAAuziP.jpg:large&quot;
                data-resolved-url-large=&quot;https://pbs.twimg.com/media/B9Aylf5IMAAuziP.jpg:large&quot;
                href=&quot;//twitter.com/Jalopnik/status/563005573290287105/photo/1&quot;&gt;&#10;
                &lt;div class=&quot;&quot;&gt;&#10; &lt;img src=&quot;
                https://pbs.twimg.com/media/B9Aylf5IMAAuziP.jpg&quot;
                alt=&quot;Embedded image permalink&quot; width=&quot;636&quot; height=&quot;309&quot;&gt;&#10;
                &lt;/div&gt;&#10;&#10;  &lt;/a&gt;&#10;&#10;  &lt;div class=&quot;cards-content&quot;&gt;&#10;
                &lt;div class=&quot;byline&quot;&gt;&#10;      &#10;    &lt;/div&gt;&#10;    &#10;  &lt;/div&gt;&#10;
                &#10;&lt;/div&gt;&#10;&#10;&#10;&#10;&#10;&lt;/div&gt;&#10;&#10;&#10;&#10;  &lt;div
                class=&quot;js-machine-translated-tweet-container&quot;&gt;&lt;/div&gt;&#10;    &lt;div
                class=&quot;js-tweet-stats-container tweet-stats-container &quot;&gt;&#10;    &lt;/div&gt;&#10;&#10;
                &lt;div class=&quot;client-and-actions&quot;&gt;&#10;  &lt;span class=&quot;metadata&quot;&gt;&#10;
                &lt;span&gt;5:06 PM - 4 Feb 2015&lt;/span&gt;&#10;&#10;       &amp;middot; &lt;a
                class=&quot;permalink-link js-permalink js-nav&quot; href=&quot;/Jalopnik/status/563005573290287105
                &quot;tabindex=&quot;-1&quot;&gt;Details&lt;/a&gt;&#10;    &#10;&#10;        &#10;        &#10;
                &#10;&#10;  &lt;/span&gt;&#10;&lt;/div&gt;&#10;&#10;&#10;&lt;/div&gt;&#10;" data-you-follow="false"
                data-you-block="false">
                <div class="context">
                </div>
                <div class="content">
                    <div class="stream-item-header">
                        <a class="account-group js-account-group js-action-profile js-user-profile-link js-nav"
                            href="/Jalopnik" data-user-id="3060631">
                            <img class="avatar js-action-profile-avatar"
                                src="https://pbs.twimg.com/profile_images/2976430168/5cd4a59_bigger.jpeg" alt="">
                            <strong class="fullname js-action-profile-name show-popup-with-id" data-aria-label-part>
                                Jalopnik
                            </strong>
                            <span>&rlm;</span>
                            <span class="username js-action-profile-name" data-aria-label-part>
                            <s>@</s><b>TitleName</b>
                            </span>
                        </a>
                        <small class="time">
                        <a href="/this.is.the.url"
                            class="tweet-timestamp js-permalink js-nav js-tooltip" title="5:06 PM - 4 Feb 2015" >
                            <span class="_timestamp js-short-timestamp js-relative-timestamp"  data-time="1423065963"
                                data-time-ms="1423065963000" data-long-form="true" aria-hidden="true">
                                17m
                            </span>
                            <span class="u-hiddenVisually" data-aria-label-part="last">17 minutes ago</span>
                        </a>
                        </small>
                    </div>
                    <p class="js-tweet-text tweet-text" lang="en" data-aria-label-part="0">
                        This is the content étude à€
                        <a href="http://t.co/nRWsqQAwBL" rel="nofollow" dir="ltr"
                            data-expanded-url="http://jalo.ps/ReMENu4" class="twitter-timeline-link"
                            target="_blank" title="http://jalo.ps/ReMENu4" >
                        <span class="tco-ellipsis">
                        </span>
                        <span class="invisible">http://</span><span class="js-display-url">link.in.tweet</span>
                        <span class="invisible"></span>
                        <span class="tco-ellipsis">
                            <span class="invisible">&nbsp;</span>
                        </span>
                    </a>
                    <a href="http://t.co/rbFsfeE0l3" class="twitter-timeline-link u-hidden"
                        data-pre-embedded="true" dir="ltr">
                        pic.twitter.com/rbFsfeE0l3
                    </a>
                    </p>
                    <div class="expanded-content js-tweet-details-dropdown">
                    </div>
                    <div class="stream-item-footer">
                        <a class="details with-icn js-details" href="/Jalopnik/status/563005573290287105">
                            <span class="Icon Icon--photo">
                            </span>
                            <b>
                                <span class="expand-stream-item js-view-details">
                                    View photo
                                </span>
                                <span class="collapse-stream-item  js-hide-details">
                                    Hide photo
                                </span>
                            </b>
                        </a>
                        <span class="ProfileTweet-action--reply u-hiddenVisually">
                            <span class="ProfileTweet-actionCount" aria-hidden="true" data-tweet-stat-count="0">
                                <span class="ProfileTweet-actionCountForAria" >0 replies</span>
                            </span>
                        </span>
                        <span class="ProfileTweet-action--retweet u-hiddenVisually">
                            <span class="ProfileTweet-actionCount"  data-tweet-stat-count="8">
                                <span class="ProfileTweet-actionCountForAria" data-aria-label-part>8 retweets</span>
                            </span>
                        </span>
                        <span class="ProfileTweet-action--favorite u-hiddenVisually">
                            <span class="ProfileTweet-actionCount"  data-tweet-stat-count="14">
                                <span class="ProfileTweet-actionCountForAria" data-aria-label-part>14 favorites</span>
                            </span>
                        </span>
                        <div role="group" aria-label="Tweet actions" class="ProfileTweet-actionList u-cf js-actions">
                            <div class="ProfileTweet-action ProfileTweet-action--reply">
                                <button class="ProfileTweet-actionButton u-textUserColorHover js-actionButton
                                    js-actionReply" data-modal="ProfileTweet-reply" type="button" title="Reply">
                                    <span class="Icon Icon--reply">
                                    </span>
                                    <span class="u-hiddenVisually">Reply</span>
                                    <span class="ProfileTweet-actionCount u-textUserColorHover
                                        ProfileTweet-actionCount--isZero">
                                        <span class="ProfileTweet-actionCountForPresentation" aria-hidden="true">
                                        </span>
                                    </span>
                                </button>
                            </div>
                            <div class="ProfileTweet-action ProfileTweet-action--retweet js-toggleState js-toggleRt">
                                <button class="ProfileTweet-actionButton  js-actionButton js-actionRetweet js-tooltip"
                                    title="Retweet" data-modal="ProfileTweet-retweet" type="button">
                                    <span class="Icon Icon--retweet">
                                    </span>
                                    <span class="u-hiddenVisually">Retweet</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">8</span>
                                    </span>
                                </button>
                                <button class="ProfileTweet-actionButtonUndo js-actionButton js-actionRetweet"
                                    data-modal="ProfileTweet-retweet" title="Undo retweet" type="button">
                                    <span class="Icon Icon--retweet">
                                    </span>
                                    <span class="u-hiddenVisually">Retweeted</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">8</span>
                                    </span>
                                </button>
                            </div>
                            <div class="ProfileTweet-action ProfileTweet-action--favorite js-toggleState">
                                <button class="ProfileTweet-actionButton js-actionButton js-actionFavorite js-tooltip"
                                    title="Favorite" type="button">
                                    <span class="Icon Icon--favorite">
                                    </span>
                                    <span class="u-hiddenVisually">Favorite</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">14</span>
                                    </span>
                                </button>
                                <button class="ProfileTweet-actionButtonUndo u-linkClean js-actionButton
                                    js-actionFavorite" title="Undo favorite" type="button">
                                    <span class="Icon Icon--favorite">
                                    </span>
                                    <span class="u-hiddenVisually">Favorited</span>
                                    <span class="ProfileTweet-actionCount">
                                        <span class="ProfileTweet-actionCountForPresentation">
                                            14
                                        </span>
                                    </span>
                                </button>
                            </div>
                            <div class="ProfileTweet-action ProfileTweet-action--more js-more-ProfileTweet-actions">
                                <div class="dropdown">
                                    <button class="ProfileTweet-actionButton u-textUserColorHover dropdown-toggle
                                        js-tooltip js-dropdown-toggle" type="button" title="More">
                                        <span class="Icon Icon--dots">
                                        </span>
                                        <span class="u-hiddenVisually">More</span>
                                    </button>
                                    <div class="dropdown-menu">
                                        <div class="dropdown-caret">
                                            <div class="caret-outer">
                                            </div>
                                            <div class="caret-inner">
                                            </div>
                                        </div>
                                        <ul>
                                            <li class="share-via-dm js-actionShareViaDM" data-nav="share_tweet_dm">
                                                <button type="button" class="dropdown-link">
                                                    Share via Direct Message
                                                </button>
                                            </li>
                                            <li class="embed-link js-actionEmbedTweet" data-nav="embed_tweet">
                                                <button type="button" class="dropdown-link">
                                                    Embed Tweet
                                                </button>
                                            </li>
                                            <li class="mute-user-item pretty-link">
                                                <button type="button" class="dropdown-link">
                                                    Mute
                                                </button>
                                            </li>
                                            <li class="unmute-user-item pretty-link">
                                                <button type="button" class="dropdown-link">
                                                    Unmute
                                                </button>
                                            </li>
                                            <li class="block-or-report-link js-actionBlockOrReport"
                                                data-nav="block_or_report">
                                                <button type="button" class="dropdown-link">
                                                    Block or report
                                                </button>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </li>
        """
        response = mock.Mock(text=html)
        results = twitter.response(response)
        self.assertEqual(type(results), list)
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['title'], '@TitleName')
        self.assertEqual(results[0]['url'], 'https://twitter.com/this.is.the.url')
        self.assertIn(u'This is the content', results[0]['content'])

        html = """
        <li class="b_algo" u="0|5109|4755453613245655|UAGjXgIrPH5yh-o5oNHRx_3Zta87f_QO">
            <div Class="sa_mc">
                <div class="sb_tlst">
                    <h2>
                        <a href="http://this.should.be.the.link/" h="ID=SERP,5124.1">
                        <strong>This</strong> should be the title</a>
                    </h2>
                </div>
                <div class="sb_meta">
                <cite>
                <strong>this</strong>.meta.com</cite>
                    <span class="c_tlbxTrg">
                        <span class="c_tlbxH" H="BASE:CACHEDPAGEDEFAULT" K="SERP,5125.1">
                        </span>
                    </span>
                </div>
                <p>
                <strong>This</strong> should be the content.</p>
            </div>
        </li>
        """
        response = mock.Mock(text=html)
        results = twitter.response(response)
        self.assertEqual(type(results), list)
        self.assertEqual(len(results), 0)