@@ -0,0 +1,169 @@
1+from collections import defaultdict
3+from searx.engines import subtitleseeker
4+from searx.testing import SearxTestCase
7+class TestSubtitleseekerEngine(SearxTestCase):
9+ def test_request(self):
11+ dicto = defaultdict(dict)
13+ params = subtitleseeker.request(query, dicto)
14+ self.assertTrue('url' in params)
15+ self.assertTrue(query in params['url'])
16+ self.assertTrue('subtitleseeker.com' in params['url'])
18+ def test_response(self):
19+ dicto = defaultdict(dict)
20+ dicto['language'] = 'fr_FR'
21+ response = mock.Mock(search_params=dicto)
23+ self.assertRaises(AttributeError, subtitleseeker.response, None)
24+ self.assertRaises(AttributeError, subtitleseeker.response, [])
25+ self.assertRaises(AttributeError, subtitleseeker.response, '')
26+ self.assertRaises(AttributeError, subtitleseeker.response, '[]')
28+ response = mock.Mock(text='<html></html>', search_params=dicto)
29+ self.assertEqual(subtitleseeker.response(response), [])
32+ <div class="boxRows">
33+ <div class="boxRowsInner" style="width:600px;">
34+ <img src="http://static.subtitleseeker.com/images/movie.gif"
35+ style="width:16px; height:16px;" class="icon">
36+ <a href="http://this.is.the.url/"
37+ class="blue" title="Title subtitle" >
41+ <span class="f10b grey-dark arial" style="padding:0px 0px 5px 20px">
45+ <div class="boxRowsInner f12b red" style="width:70px;">
48+ <div class="boxRowsInner grey-web f12" style="width:120px;">
49+ <img src="http://static.subtitleseeker.com/images/basket_put.png"
50+ style="width:16px; height:16px;" class="icon">
53+ <div class="boxRowsInner grey-web f10" style="width:130px;">
54+ <img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
55+ style="width:16px; height:16px;" class="icon">
58+ <div class="clear"></div>
61+ response = mock.Mock(text=html, search_params=dicto)
62+ results = subtitleseeker.response(response)
63+ self.assertEqual(type(results), list)
64+ self.assertEqual(len(results), 1)
65+ self.assertEqual(results[0]['title'], 'This is the Title')
66+ self.assertEqual(results[0]['url'], 'http://this.is.the.url/French/')
67+ self.assertIn('1998', results[0]['content'])
68+ self.assertIn('1039 Subs', results[0]['content'])
69+ self.assertIn('Alternative Title', results[0]['content'])
72+ <div class="boxRows">
73+ <div class="boxRowsInner" style="width:600px;">
74+ <img src="http://static.subtitleseeker.com/images/movie.gif"
75+ style="width:16px; height:16px;" class="icon">
76+ <a href="http://this.is.the.url/"
77+ class="blue" title="Title subtitle" >
81+ <div class="boxRowsInner f12b red" style="width:70px;">
84+ <div class="boxRowsInner grey-web f12" style="width:120px;">
85+ <img src="http://static.subtitleseeker.com/images/basket_put.png"
86+ style="width:16px; height:16px;" class="icon">
89+ <div class="boxRowsInner grey-web f10" style="width:130px;">
90+ <img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
91+ style="width:16px; height:16px;" class="icon">
94+ <div class="clear"></div>
97+ dicto['language'] = 'all'
98+ response = mock.Mock(text=html, search_params=dicto)
99+ results = subtitleseeker.response(response)
100+ self.assertEqual(type(results), list)
101+ self.assertEqual(len(results), 1)
102+ self.assertEqual(results[0]['title'], 'This is the Title')
103+ self.assertEqual(results[0]['url'], 'http://this.is.the.url/')
104+ self.assertIn('1998', results[0]['content'])
105+ self.assertIn('1039 Subs', results[0]['content'])
108+ <div class="boxRows">
109+ <div class="boxRowsInner" style="width:600px;">
110+ <img src="http://static.subtitleseeker.com/images/movie.gif"
111+ style="width:16px; height:16px;" class="icon">
112+ <a href="http://this.is.the.url/"
113+ class="blue" title="Title subtitle" >
117+ <div class="boxRowsInner f12b red" style="width:70px;">
120+ <div class="boxRowsInner grey-web f12" style="width:120px;">
121+ <img src="http://static.subtitleseeker.com/images/basket_put.png"
122+ style="width:16px; height:16px;" class="icon">
125+ <div class="boxRowsInner grey-web f10" style="width:130px;">
126+ <img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
127+ style="width:16px; height:16px;" class="icon">
130+ <div class="clear"></div>
133+ subtitleseeker.language = 'English'
134+ response = mock.Mock(text=html, search_params=dicto)
135+ results = subtitleseeker.response(response)
136+ self.assertEqual(type(results), list)
137+ self.assertEqual(len(results), 1)
138+ self.assertEqual(results[0]['title'], 'This is the Title')
139+ self.assertEqual(results[0]['url'], 'http://this.is.the.url/English/')
140+ self.assertIn('1998', results[0]['content'])
141+ self.assertIn('1039 Subs', results[0]['content'])
144+ <div class="boxRowsInner" style="width:600px;">
145+ <img src="http://static.subtitleseeker.com/images/movie.gif"
146+ style="width:16px; height:16px;" class="icon">
147+ <a href="http://this.is.the.url/"
148+ class="blue" title="Title subtitle" >
152+ <div class="boxRowsInner f12b red" style="width:70px;">
155+ <div class="boxRowsInner grey-web f12" style="width:120px;">
156+ <img src="http://static.subtitleseeker.com/images/basket_put.png"
157+ style="width:16px; height:16px;" class="icon">
160+ <div class="boxRowsInner grey-web f10" style="width:130px;">
161+ <img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
162+ style="width:16px; height:16px;" class="icon">
166+ response = mock.Mock(text=html, search_params=dicto)
167+ results = subtitleseeker.response(response)
168+ self.assertEqual(type(results), list)
169+ self.assertEqual(len(results), 0)