Commit ff600724 authored by Gaël Duval's avatar Gaël Duval 🏄🏼
Browse files

Merge branch 'nicofonk/fix-encoding' into 'master'

Revert wrong encoding changes

See merge request e/cloud/my-spot!23
parents c57f0c73 e9ba2366
......@@ -82,7 +82,7 @@ def request(query, params):
def response(resp):
results = []
rss = etree.fromstring(resp.content.encode())
rss = etree.fromstring(resp.content)
ns = rss.nsmap
......
......@@ -65,7 +65,7 @@ def replace_pua_chars(text):
def response(resp):
results = []
search_results = etree.XML(resp.text.encode())
search_results = etree.XML(resp.text)
# return empty array if there are no results
if search_results.xpath(failure_xpath):
......
......@@ -33,13 +33,13 @@ class TestBingNewsEngine(TestCase):
self.assertRaises(AttributeError, bing_news.response, '')
self.assertRaises(AttributeError, bing_news.response, '[]')
response = mock.Mock(content='<html></html>')
response = mock.Mock(content=b'<html></html>')
self.assertEqual(bing_news.response(response), [])
response = mock.Mock(content='<html></html>')
response = mock.Mock(content=b'<html></html>')
self.assertEqual(bing_news.response(response), [])
html = """<?xml version="1.0" encoding="utf-8" ?>
html = b"""<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:News="https://www.bing.com:443/news/search?q=python&amp;setmkt=en-US&amp;first=1&amp;format=RSS">
<channel>
<title>python - Bing News</title>
......@@ -84,7 +84,7 @@ class TestBingNewsEngine(TestCase):
self.assertEqual(results[1]['content'], 'Another Article Content')
self.assertNotIn('img_src', results[1])
html = """<?xml version="1.0" encoding="utf-8" ?>
html = b"""<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:News="https://www.bing.com:443/news/search?q=python&amp;setmkt=en-US&amp;first=1&amp;format=RSS">
<channel>
<title>python - Bing News</title>
......@@ -119,7 +119,7 @@ class TestBingNewsEngine(TestCase):
self.assertEqual(results[0]['content'], 'Article Content')
self.assertEqual(results[0]['img_src'], 'http://another.bing.com/image')
html = """<?xml version="1.0" encoding="utf-8" ?>
html = b"""<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:News="https://www.bing.com:443/news/search?q=python&amp;setmkt=en-US&amp;first=1&amp;format=RSS">
<channel>
<title>python - Bing News</title>
......@@ -138,6 +138,6 @@ class TestBingNewsEngine(TestCase):
self.assertEqual(type(results), list)
self.assertEqual(len(results), 0)
html = """<?xml version="1.0" encoding="utf-8" ?>gabarge"""
html = b"""<?xml version="1.0" encoding="utf-8" ?>gabarge"""
response = mock.Mock(content=html)
self.assertRaises(lxml.etree.XMLSyntaxError, bing_news.response, response)
......@@ -32,14 +32,14 @@ class TestWolframAlphaAPIEngine(TestCase):
request = Request(headers={'Referer': referer_url})
# test failure
xml = '''<?xml version='1.0' encoding='UTF-8'?>
xml = b'''<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='false' error='false' />
'''
response = mock.Mock(text=xml)
self.assertEqual(wolframalpha_api.response(response), [])
# test basic case
xml = """<?xml version='1.0' encoding='UTF-8'?>
xml = b"""<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='true'
error='false'
numpods='3'
......@@ -107,7 +107,7 @@ class TestWolframAlphaAPIEngine(TestCase):
self.assertIn('result_plaintext', results[1]['content'])
# test calc
xml = """<?xml version='1.0' encoding='UTF-8'?>
xml = b"""<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='true'
error='false'
numpods='2'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment