@@ -2,7 +2,6 @@
4from urlparse import ParseResult
4from urlparse import ParseResult
6from searx import webapp
5from searx import webapp
7from searx.testing import SearxTestCase
6from searx.testing import SearxTestCase
@@ -33,6 +32,11 @@ class ViewsTestCase(SearxTestCase):
35+ def search_mock(search_self, *args):
36+ search_self.results = self.test_results
38+ webapp.Search.search = search_mock
36 self.maxDiff = None # to see full diffs
40 self.maxDiff = None # to see full diffs
38 def test_index_empty(self):
42 def test_index_empty(self):
@@ -40,14 +44,7 @@ class ViewsTestCase(SearxTestCase):
40 self.assertEqual(result.status_code, 200)
44 self.assertEqual(result.status_code, 200)
41 self.assertIn('<div class="title"><h1>searx</h1></div>', result.data)
45 self.assertIn('<div class="title"><h1>searx</h1></div>', result.data)
43− @patch('searx.search.Search.search')
44− def test_index_html(self, search):
47+ def test_index_html(self):
45− search.return_value = (
51 result = self.app.post('/', data={'q': 'test'})
48 result = self.app.post('/', data={'q': 'test'})
52 self.assertIn(
49 self.assertIn(
53 '<h3 class="result_title"><img width="14" height="14" class="favicon" src="/static/themes/default/img/icons/icon_youtube.ico" alt="youtube" /><a href="http://second.test.xyz">Second <span class="highlight">Test</span></a></h3>', # noqa
50 '<h3 class="result_title"><img width="14" height="14" class="favicon" src="/static/themes/default/img/icons/icon_youtube.ico" alt="youtube" /><a href="http://second.test.xyz">Second <span class="highlight">Test</span></a></h3>', # noqa
@@ -58,14 +55,7 @@ class ViewsTestCase(SearxTestCase):
58 result.data
55 result.data
61− @patch('searx.search.Search.search')
62− def test_index_json(self, search):
58+ def test_index_json(self):
63− search.return_value = (
69 result = self.app.post('/', data={'q': 'test', 'format': 'json'})
59 result = self.app.post('/', data={'q': 'test', 'format': 'json'})
71 result_dict = json.loads(result.data)
61 result_dict = json.loads(result.data)
@@ -76,14 +66,7 @@ class ViewsTestCase(SearxTestCase):
76 self.assertEqual(
66 self.assertEqual(
77 result_dict['results'][0]['url'], 'http://first.test.xyz')
67 result_dict['results'][0]['url'], 'http://first.test.xyz')
79− @patch('searx.search.Search.search')
80− def test_index_csv(self, search):
69+ def test_index_csv(self):
81− search.return_value = (
87 result = self.app.post('/', data={'q': 'test', 'format': 'csv'})
70 result = self.app.post('/', data={'q': 'test', 'format': 'csv'})
89 self.assertEqual(
72 self.assertEqual(
@@ -93,14 +76,7 @@ class ViewsTestCase(SearxTestCase):
93 result.data
76 result.data
96− @patch('searx.search.Search.search')
97− def test_index_rss(self, search):
79+ def test_index_rss(self):
98− search.return_value = (
104 result = self.app.post('/', data={'q': 'test', 'format': 'rss'})
80 result = self.app.post('/', data={'q': 'test', 'format': 'rss'})
106 self.assertIn(
82 self.assertIn(