[testlib] make test_view load the json data
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 25 Feb 2013 18:02:11 +0100
changeset 8704 933f9693c53d
parent 8703 db3164d09765
child 8705 5b3e17a63fad
[testlib] make test_view load the json data Closes #2721472
devtools/testlib.py
web/test/unittest_views_json.py
--- a/devtools/testlib.py	Mon Feb 11 12:06:16 2013 +0100
+++ b/devtools/testlib.py	Mon Feb 25 18:02:11 2013 +0100
@@ -85,8 +85,7 @@
 
 class JsonValidator(object):
     def parse_string(self, data):
-        json.loads(data)
-        return data
+        return json.loads(data)
 
 # email handling, to test emails sent by an application ########################
 
--- a/web/test/unittest_views_json.py	Mon Feb 11 12:06:16 2013 +0100
+++ b/web/test/unittest_views_json.py	Mon Feb 25 18:02:11 2013 +0100
@@ -35,14 +35,14 @@
         rset = req.execute('Any GN,COUNT(X) GROUPBY GN ORDERBY GN WHERE X in_group G, G name GN')
         data = self.view('jsonexport', rset)
         self.assertEqual(req.headers_out.getRawHeaders('content-type'), ['application/json'])
-        self.assertEqual(data, '[["guests", 1], ["managers", 1]]')
+        self.assertListEqual(data, [["guests", 1], ["managers", 1]])
 
     def test_json_rsetexport_empty_rset(self):
         req = self.request()
         rset = req.execute('Any X WHERE X is CWUser, X login "foobarbaz"')
         data = self.view('jsonexport', rset)
         self.assertEqual(req.headers_out.getRawHeaders('content-type'), ['application/json'])
-        self.assertEqual(data, '[]')
+        self.assertListEqual(data, [])
 
     def test_json_rsetexport_with_jsonp(self):
         req = self.request()
@@ -68,7 +68,7 @@
     def test_json_ersetexport(self):
         req = self.request()
         rset = req.execute('Any G ORDERBY GN WHERE G is CWGroup, G name GN')
-        data = json.loads(self.view('ejsonexport', rset))
+        data = self.view('ejsonexport', rset)
         self.assertEqual(req.headers_out.getRawHeaders('content-type'), ['application/json'])
         self.assertEqual(data[0]['name'], 'guests')
         self.assertEqual(data[1]['name'], 'managers')