From d997265e5599333b4316561ca18a8f4131e3e2d9 Mon Sep 17 00:00:00 2001 From: a01200356 Date: Sun, 3 Jan 2016 19:57:37 -0600 Subject: add tests for unicode strings in wolframalpha --- searx/tests/engines/test_wolframalpha_noapi.py | 250 ++++++++----------------- 1 file changed, 77 insertions(+), 173 deletions(-) (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 index 237f578db..3b6314672 100644 --- a/searx/tests/engines/test_wolframalpha_noapi.py +++ b/searx/tests/engines/test_wolframalpha_noapi.py @@ -40,7 +40,7 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase): """ - + # test failed query response = mock.Mock(text=html) self.assertEqual(wolframalpha_noapi.response(response), []) @@ -51,113 +51,30 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase): """ + # test plaintext response = mock.Mock(text=html) results = wolframalpha_noapi.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 2) - self.assertIn("i", results[0]['answer']) - self.assertIn("sqrt(-1) - Wolfram|Alpha", results[1]['title']) - self.assertIn("http://www.wolframalpha.com/input/?i=+sqrt%28-1%29", results[1]['url']) + 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 = """ @@ -165,91 +82,78 @@ class TestWolframAlphaNoAPIEngine(SearxTestCase): + + + """ + # 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']) - //false - try { + 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']) - $("#results #pod_0200:not(iframe #pod_0200)") - .add("#showsteps #pod_0200:not(iframe #pod_0200)") - .add(".results-pod #pod_0200:not(iframe #pod_0200)") - .data("tempFileID", '') - .data("podIdentifier", '\x22Plot\x22') - .data("podShortIdentifier", '') - .data("buttonStates", '') - .data("scanner", '\x22\x22'); - $("#results #pod_0200-popup:not(iframe #pod_0200-popup)") - .add("#showsteps #pod_0200-popup:not(iframe #pod_0200-popup)") - .add(".results-pod #pod_0200-popup:not(iframe #pod_0200-popup)") - .data("tempFileID", '') - .data("podIdentifier", '\x22Plot\x22') - .data("podShortIdentifier", '') - .data("buttonStates", '') - .data("scanner", '\x22\x22'); + html = """ + + 1 euro to yen - Wolfram|Alpha + + + """ + # test output in htmlentity 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.assertIn("http://www.wolframalpha.com/input/?i=+integral+1%2Fx", results[1]['url']) + 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']) -- cgit v1.2.3