# HG changeset patch # User Sylvain Thénault # Date 1358439126 -3600 # Node ID 7812093e21f7fc7a7bc91ccc6070bcfa1202b7ac # Parent 353bbd17a8b619c42c414b9969fe7ec066f3b93e [testlib] test_view now parse json data, closes #2557467 diff -r 353bbd17a8b6 -r 7812093e21f7 devtools/testlib.py --- a/devtools/testlib.py Thu Jan 17 14:39:51 2013 +0100 +++ b/devtools/testlib.py Thu Jan 17 17:12:06 2013 +0100 @@ -1,4 +1,4 @@ -# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -45,6 +45,7 @@ from cubicweb import ValidationError, NoSelectableObject, AuthenticationError from cubicweb import cwconfig, dbapi, devtools, web, server +from cubicweb.utils import json from cubicweb.sobjects import notification from cubicweb.web import Redirect, application from cubicweb.server.session import Session, security_enabled @@ -85,6 +86,11 @@ protected_entities = yams.schema.BASE_TYPES.union(SYSTEM_ENTITIES) return set(schema.entities()) - protected_entities +class JsonValidator(object): + def parse_string(self, data): + json.loads(data) + return data + # email handling, to test emails sent by an application ######################## MAILBOX = [] @@ -793,11 +799,11 @@ #'application/xhtml+xml': DTDValidator, 'application/xml': htmlparser.SaxOnlyValidator, 'text/xml': htmlparser.SaxOnlyValidator, + 'application/json': JsonValidator, 'text/plain': None, 'text/comma-separated-values': None, 'text/x-vcard': None, 'text/calendar': None, - 'application/json': None, 'image/png': None, } # maps vid : validator name (override content_type_validators)