@@ -22,37 +22,64 @@ class TestGigablastEngine(SearxTestCase):
22 self.assertRaises(AttributeError, gigablast.response, '')
22 self.assertRaises(AttributeError, gigablast.response, '')
23 self.assertRaises(AttributeError, gigablast.response, '[]')
23 self.assertRaises(AttributeError, gigablast.response, '[]')
25− response = mock.Mock(content='<response></response>')
25+ response = mock.Mock(text='{"results": []}')
26 self.assertEqual(gigablast.response(response), [])
26 self.assertEqual(gigablast.response(response), [])
28− response = mock.Mock(content='<response></response>')
28+ json = """{"results": [
29− self.assertEqual(gigablast.response(response), [])
29+ {
30−
30+ "title":"South by Southwest 2016 Music, Film and Interactive Festivals - Austin Texas",
31− xml = """<?xml version="1.0" encoding="UTF-8" ?>
31+ "dmozEntry":{
32− <response>
32+ "dmozCatId":1041152,
33− <hits>5941888</hits>
33+ "directCatId":1,
34− <moreResultsFollow>1</moreResultsFollow>
34+ "dmozCatStr":"Top: Regional: North America: United States: Texas: Arts and Entertainment: Events",
35− <result>
35+ "dmozTitle":"South by Southwest (SXSW)",
36− <title><![CDATA[This should be the title]]></title>
36+ "dmozSum":"Annual music, film, and interactive conference and festival held in Austin. Includes schedules and band and film lists.",
37− <sum><![CDATA[This should be the content.]]></sum>
37+ "dmozAnchor":""
38− <url><![CDATA[http://this.should.be.the.link/]]></url>
38+ },
42+ "dmozCatStr":"Top: Regional: North America: United States: Texas: Localities: A: Austin: Arts and Entertainment: Events",
43+ "dmozTitle":"South by Southwest (SXSW)",
45+ "dmozAnchor":"www.sxsw.com"
50+ "dmozCatStr":"Top: Regional: North America: United States: Texas: Travel and Tourism: Attractions",
51+ "dmozTitle":"South by Southwest (SXSW)",
52+ "dmozSum":"Music, film, and interactive conference and festival. Includes schedules and band and film lists.",
55+ "indirectDmozCatId":1041152,
56+ "indirectDmozCatId":763945,
57+ "indirectDmozCatId":761446,
58+ "contentType":"html",
59+ "sum":"This should be the content.",
60+ "url":"www.sxsw.com",
39− <size>90.5</size>
62+ "size":" 102k",
40− <docId>145414002633</docId>
63+ "sizeInBytes":104306,
41− <siteId>2660021087</siteId>
64+ "bytesUsedToComputeSummary":70000,
42− <domainId>2660021087</domainId>
65+ "docId":269411794364,
43− <spidered>1320519373</spidered>
66+ "docScore":586571136.000000,
44− <indexed>1320519373</indexed>
67+ "summaryGenTimeMS":12,
45− <pubdate>4294967295</pubdate>
68+ "summaryTagdbLookupTimeMS":0,
46− <isModDate>0</isModDate>
69+ "summaryTitleRecLoadTimeMS":1,
70+ "site":"www.sxsw.com",
71+ "spidered":1452203608,
72+ "firstIndexedDateUTC":1444167123,
73+ "contentHash32":2170650347,
47− <language><![CDATA[English]]></language>
74+ "language":"English",
48− <charset><![CDATA[UTF-8]]></charset>
75+ "langAbbr":"en"
52− response = mock.Mock(content=xml)
79+ response = mock.Mock(text=json)
53 results = gigablast.response(response)
80 results = gigablast.response(response)
54 self.assertEqual(type(results), list)
81 self.assertEqual(type(results), list)
55 self.assertEqual(len(results), 1)
82 self.assertEqual(len(results), 1)
56− self.assertEqual(results[0]['title'], 'This should be the title')
83+ self.assertEqual(results[0]['title'], 'South by Southwest 2016 Music, Film and Interactive Festivals - Austin Texas')
57− self.assertEqual(results[0]['url'], 'http://this.should.be.the.link/')
84+ self.assertEqual(results[0]['url'], 'www.sxsw.com')
58 self.assertEqual(results[0]['content'], 'This should be the content.')
85 self.assertEqual(results[0]['content'], 'This should be the content.')