devtools/testlib.py
changeset 563 a690996639ca
parent 562 bdadb26c4a3c
child 823 cb8ccbef8fa5
child 1004 625e59773119
equal deleted inserted replaced
562:bdadb26c4a3c 563:a690996639ca
    76     if after is None:
    76     if after is None:
    77         after = before
    77         after = before
    78     return center - before <= line_no <= center + after
    78     return center - before <= line_no <= center + after
    79 
    79 
    80 ## base webtest class #########################################################
    80 ## base webtest class #########################################################
       
    81 VALMAP = {None: None, 'dtd': DTDValidator, 'xml': SaxOnlyValidator}
       
    82 
    81 class WebTest(EnvBasedTC):
    83 class WebTest(EnvBasedTC):
    82     """base class for web tests"""
    84     """base class for web tests"""
    83     __abstract__ = True
    85     __abstract__ = True
    84 
    86 
    85     pdbclass = CubicWebDebugger
    87     pdbclass = CubicWebDebugger
    91     # validators availables are :
    93     # validators availables are :
    92     #  DTDValidator : validates XML + declared DTD
    94     #  DTDValidator : validates XML + declared DTD
    93     #  SaxOnlyValidator : guarantees XML is well formed
    95     #  SaxOnlyValidator : guarantees XML is well formed
    94     #  None : do not try to validate anything
    96     #  None : do not try to validate anything
    95     # validators used must be imported from from.devtools.htmlparser
    97     # validators used must be imported from from.devtools.htmlparser
    96     valmap = {None: None, 'dtd': DTDValidator, 'xml': SaxOnlyValidator}
       
    97     content_type_validators = {
    98     content_type_validators = {
    98         # maps MIME type : validator name
    99         # maps MIME type : validator name
    99         #
   100         #
   100         # do not set html validators here, we need HTMLValidator for html
   101         # do not set html validators here, we need HTMLValidator for html
   101         # snippets
   102         # snippets
   109         'text/calendar': None,
   110         'text/calendar': None,
   110         'application/json': None,
   111         'application/json': None,
   111         'image/png': None,
   112         'image/png': None,
   112         }
   113         }
   113     # maps vid : validator name (override content_type_validators)
   114     # maps vid : validator name (override content_type_validators)
   114     vid_validators = dict((vid, valmap[valkey])
   115     vid_validators = dict((vid, VALMAP[valkey])
   115                           for vid, valkey in VIEW_VALIDATORS.iteritems())
   116                           for vid, valkey in VIEW_VALIDATORS.iteritems())
   116     
   117     
   117     no_auto_populate = ()
   118     no_auto_populate = ()
   118     ignored_relations = ()    
   119     ignored_relations = ()    
   119         
   120