From a605d0ae698e8a5555935780d83df50b06727f24 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sun, 1 Feb 2015 13:52:43 +0100 Subject: [PATCH] [enh] add test for 1x.com --- searx/engines/www1x.py | 3 +- searx/tests/engines/test_www1x.py | 57 +++++++++++++++++++++++++++++++ searx/tests/test_engines.py | 1 + 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 searx/tests/engines/test_www1x.py diff --git a/searx/engines/www1x.py b/searx/engines/www1x.py index d10c4ca37..a68c105ce 100644 --- a/searx/engines/www1x.py +++ b/searx/engines/www1x.py @@ -36,7 +36,8 @@ def response(resp): results = [] # get links from result-text - results_parts = re.split(r'(||') + self.assertEqual(www1x.response(response), []) + html = """ + + + + + + + ] + > + + +
Photos
+ + + + ]]>
+ """ + response = mock.Mock(text=html) + results = www1x.response(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 1) + self.assertEqual(results[0]['url'], 'http://1x.com/photo/123456') + self.assertEqual(results[0]['thumbnail_src'], 'http://1x.com/images/user/testimage-123456.jpg') + self.assertEqual(results[0]['content'], '') + self.assertEqual(results[0]['template'], 'images.html') diff --git a/searx/tests/test_engines.py b/searx/tests/test_engines.py index 1ffdbe529..cfd7fa26a 100644 --- a/searx/tests/test_engines.py +++ b/searx/tests/test_engines.py @@ -1,2 +1,3 @@ from searx.tests.engines.test_dummy import * # noqa from searx.tests.engines.test_github import * # noqa +from searx.tests.engines.test_www1x import * # noqa