From c2e034f52a31d4eb84b01cafb3af70ed55dad792 Mon Sep 17 00:00:00 2001 From: a01200356 Date: Sun, 10 Jan 2016 19:51:40 -0600 Subject: move two tests --- searx/tests/engines/test_wolframalpha_noapi.py | 193 ------------------------- 1 file changed, 193 deletions(-) delete mode 100644 searx/tests/engines/test_wolframalpha_noapi.py (limited to 'searx/tests/engines/test_wolframalpha_noapi.py') diff --git a/searx/tests/engines/test_wolframalpha_noapi.py b/searx/tests/engines/test_wolframalpha_noapi.py deleted file mode 100644 index cad9593f2..000000000 --- a/searx/tests/engines/test_wolframalpha_noapi.py +++ /dev/null @@ -1,193 +0,0 @@ -# -*- coding: utf-8 -*- -from collections import defaultdict -import mock -from searx.engines import wolframalpha_noapi -from searx.testing import SearxTestCase - - -class TestWolframAlphaNoAPIEngine(SearxTestCase): - - def test_request(self): - query = 'test_query' - dicto = defaultdict(dict) - dicto['pageno'] = 1 - params = wolframalpha_noapi.request(query, dicto) - self.assertIn('url', params) - self.assertIn(query, params['url']) - self.assertIn('wolframalpha.com', params['url']) - - def test_response(self): - self.assertRaises(AttributeError, wolframalpha_noapi.response, None) - self.assertRaises(AttributeError, wolframalpha_noapi.response, []) - self.assertRaises(AttributeError, wolframalpha_noapi.response, '') - self.assertRaises(AttributeError, wolframalpha_noapi.response, '[]') - - html = """ - - Parangaricutirimícuaro - Wolfram|Alpha - - -
-

Wolfram|Alpha doesn't know how to interpret your input.

-
-
- Tip:  - Check your spelling, and use English - -
-
-
- - - """ - # test failed query - response = mock.Mock(text=html) - self.assertEqual(wolframalpha_noapi.response(response), []) - - html = """ - - sqrt(-1) - Wolfram|Alpha - - - - - - """ - # test plaintext - response = mock.Mock(text=html) - results = wolframalpha_noapi.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 2) - self.assertEquals('i', results[0]['answer']) - self.assertIn('sqrt(-1) - Wolfram|Alpha', results[1]['title']) - self.assertEquals('http://www.wolframalpha.com/input/?i=+sqrt%28-1%29', results[1]['url']) - - html = """ - - integral 1/x - Wolfram|Alpha - - - - - - """ - # test integral - response = mock.Mock(text=html) - results = wolframalpha_noapi.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 2) - self.assertIn('log(x)+c', results[0]['answer']) - self.assertIn('integral 1/x - Wolfram|Alpha', results[1]['title']) - self.assertEquals('http://www.wolframalpha.com/input/?i=+integral+1%2Fx', results[1]['url']) - - html = """ - - ∫1/x x - Wolfram|Alpha - - - - - - """ - # test input in mathematical notation - response = mock.Mock(text=html) - results = wolframalpha_noapi.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 2) - self.assertIn('log(x)+c', results[0]['answer']) - self.assertIn('∫1/x x - Wolfram|Alpha'.decode('utf-8'), results[1]['title']) - self.assertEquals('http://www.wolframalpha.com/input/?i=+%E2%88%AB1%2Fx+%EF%9D%8Cx', results[1]['url']) - - html = """ - - 1 euro to yen - Wolfram|Alpha - - - - - - """ - # test output with htmlentity - response = mock.Mock(text=html) - results = wolframalpha_noapi.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 2) - self.assertIn('¥'.decode('utf-8'), results[0]['answer']) - self.assertIn('1 euro to yen - Wolfram|Alpha', results[1]['title']) - self.assertEquals('http://www.wolframalpha.com/input/?i=+1+euro+to+yen', results[1]['url']) - - html = """ - - distance from nairobi to kyoto in inches - Wolfram|Alpha - - - - - - """ - # test output with utf-8 character - response = mock.Mock(text=html) - results = wolframalpha_noapi.response(response) - self.assertEqual(type(results), list) - self.assertEqual(len(results), 2) - self.assertIn('4.295×10^8 inches'.decode('utf-8'), results[0]['answer']) - self.assertIn('distance from nairobi to kyoto in inches - Wolfram|Alpha', results[1]['title']) - self.assertEquals('http://www.wolframalpha.com/input/?i=+distance+from+nairobi+to+kyoto+in+inches', - results[1]['url']) -- cgit v1.2.3