|
@@ -22,80 +22,15 @@ class TestVimeoEngine(SearxTestCase):
|
22
|
22
|
self.assertRaises(AttributeError, vimeo.response, '')
|
23
|
23
|
self.assertRaises(AttributeError, vimeo.response, '[]')
|
24
|
24
|
|
25
|
|
- response = mock.Mock(text='<html></html>')
|
26
|
|
- self.assertEqual(vimeo.response(response), [])
|
|
25
|
+ json = u"""
|
|
26
|
+{"filtered":{"total":274641,"page":1,"per_page":18,"paging":{"next":"?sizes=590x332&page=2","previous":null,"first":"?sizes=590x332&page=1","last":"?sizes=590x332&page=15258"},"data":[{"is_staffpick":false,"is_featured":true,"type":"clip","clip":{"uri":"\\/videos\\/106557563","name":"Hot Rod Revue: The South","link":"https:\\/\\/vimeo.com\\/106557563","duration":4069,"created_time":"2014-09-19T03:38:04+00:00","privacy":{"view":"ptv"},"pictures":{"sizes":[{"width":"590","height":"332","link":"https:\\/\\/i.vimeocdn.com\\/video\\/489717884_590x332.jpg?r=pad","link_with_play_button":"https:\\/\\/i.vimeocdn.com\\/filter\\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F489717884_590x332.jpg&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"}]},"stats":{"plays":null},"metadata":{"connections":{"comments":{"total":0},"likes":{"total":5}},"interactions":[]},"user":{"name":"Cal Thorley","link":"https:\\/\\/vimeo.com\\/calthorley","pictures":{"sizes":[{"width":30,"height":30,"link":"https:\\/\\/i.vimeocdn.com\\/portrait\\/2545308_30x30?r=pad"},{"width":75,"height":75,"link":"https:\\/\\/i.vimeocdn.com\\/portrait\\/2545308_75x75?r=pad"},{"width":100,"height":100,"link":"https:\\/\\/i.vimeocdn.com\\/portrait\\/2545308_100x100?r=pad"},{"width":300,"height":300,"link":"https:\\/\\/i.vimeocdn.com\\/portrait\\/2545308_300x300?r=pad"}]}}}}]}};
|
27
|
27
|
|
28
|
|
- html = """
|
29
|
|
- <div id="browse_content" class="results_grid" data-search-id="696d5f8366914ec4ffec33cf7652de384976d4f4">
|
30
|
|
- <ul class="js-browse_list clearfix browse browse_videos browse_videos_thumbnails kane"
|
31
|
|
- data-stream="c2VhcmNoOjo6ZGVzYzp7InF1ZXJ5IjoidGVzdCJ9">
|
32
|
|
- <li data-position="7" data-result-id="clip_79600943">
|
33
|
|
- <div class="clip_thumbnail">
|
34
|
|
- <a href="/videoid" class="js-result_url">
|
35
|
|
- <div class="thumbnail_wrapper">
|
36
|
|
- <img src="http://image.url.webp" class="js-clip_thumbnail_image">
|
37
|
|
- <div class="overlay overlay_clip_meta">
|
38
|
|
- <div class="meta_data_footer">
|
39
|
|
- <span class="clip_upload_date">
|
40
|
|
- <time datetime="2013-11-17T08:49:09-05:00"
|
41
|
|
- title="dimanche 17 novembre 2013 08:49">Il y a 1 an</time>
|
42
|
|
- </span>
|
43
|
|
- <span class="clip_likes">
|
44
|
|
- <img src="https://f.vimeocdn.com/images_v6/svg/heart-icon.svg">2 215
|
45
|
|
- </span>
|
46
|
|
- <span class="clip_comments">
|
47
|
|
- <img src="https://f.vimeocdn.com/images_v6/svg/comment-icon.svg">75
|
48
|
|
- </span>
|
49
|
|
- <span class="overlay meta_data_footer clip_duration">01:12</span>
|
50
|
|
- </div>
|
51
|
|
- </div>
|
52
|
|
- </div>
|
53
|
|
- <span class="title">This is the title</span>
|
54
|
|
- </a>
|
55
|
|
- </div>
|
56
|
|
- <div class="clip_thumbnail_attribution">
|
57
|
|
- <a href="/fedorshmidt">
|
58
|
|
- <img src="https://i.vimeocdn.com/portrait/6628061_100x100.jpg" class="avatar">
|
59
|
|
- <span class="display_name">Fedor Shmidt</span>
|
60
|
|
- </a>
|
61
|
|
- <span class="plays">2,1M lectures</span>
|
62
|
|
- </div>
|
63
|
|
- </li>
|
64
|
|
- </ul>
|
65
|
|
- </div>
|
66
|
|
- """
|
67
|
|
- response = mock.Mock(text=html)
|
|
28
|
+""" # noqa
|
|
29
|
+ response = mock.Mock(text=json)
|
68
|
30
|
results = vimeo.response(response)
|
69
|
31
|
self.assertEqual(type(results), list)
|
70
|
32
|
self.assertEqual(len(results), 1)
|
71
|
|
- self.assertEqual(results[0]['title'], 'This is the title')
|
72
|
|
- self.assertEqual(results[0]['url'], 'https://vimeo.com/videoid')
|
|
33
|
+ self.assertEqual(results[0]['title'], u'Hot Rod Revue: The South')
|
|
34
|
+ self.assertEqual(results[0]['url'], 'https://vimeo.com/106557563')
|
73
|
35
|
self.assertEqual(results[0]['content'], '')
|
74
|
|
- self.assertEqual(results[0]['thumbnail'], 'http://image.url.webp')
|
75
|
|
- self.assertIn('/videoid', results[0]['embedded'])
|
76
|
|
-
|
77
|
|
- html = """
|
78
|
|
- <ol class="js-browse_list clearfix browse browse_videos browse_videos_thumbnails kane"
|
79
|
|
- data-stream="c2VhcmNoOjo6ZGVzYzp7InF1ZXJ5IjoidGVzdCJ9">
|
80
|
|
- <li id="clip_100785455" data-start-page="/search/page:1/sort:relevant/" data-position="1">
|
81
|
|
- <a href="/videoid" title="Futurama 3d (test shot)">
|
82
|
|
- <img src="http://image.url.webp"
|
83
|
|
- srcset="http://i.vimeocdn.com/video/482375085_590x332.webp 2x" alt=""
|
84
|
|
- class="thumbnail thumbnail_lg_wide">
|
85
|
|
- <div class="data">
|
86
|
|
- <p class="title">
|
87
|
|
- This is the title
|
88
|
|
- </p>
|
89
|
|
- <p class="meta">
|
90
|
|
- <time datetime="2014-07-15T04:16:27-04:00"
|
91
|
|
- title="mardi 15 juillet 2014 04:16">Il y a 6 mois</time>
|
92
|
|
- </p>
|
93
|
|
- </div>
|
94
|
|
- </a>
|
95
|
|
- </li>
|
96
|
|
- </ol>
|
97
|
|
- """
|
98
|
|
- response = mock.Mock(text=html)
|
99
|
|
- results = vimeo.response(response)
|
100
|
|
- self.assertEqual(type(results), list)
|
101
|
|
- self.assertEqual(len(results), 0)
|
|
36
|
+ self.assertEqual(results[0]['thumbnail'], 'https://i.vimeocdn.com/video/489717884_590x332.jpg?r=pad')
|