Example #1
0
    def test_validator(self):
        assert self.complex_in.data_format.validate == get_validator(
            'application/json')
        assert self.complex_in.validator == get_validator('application/json')
        frmt = get_data_format('application/json')

        def my_validate():
            return True

        frmt.validate = my_validate
        assert not self.complex_in.validator == frmt.validate
Example #2
0
 def data_format(self, data_format):
     """self data_format setter
     """
     if self._is_supported(data_format):
         self._data_format = data_format
         if not data_format.validate or data_format.validate == emptyvalidator:
             data_format.validate = get_validator(data_format.mime_type)
     else:
         raise InvalidParameterValue(
             "Requested format "
             "%s, %s, %s not supported" %
             (data_format.mime_type, data_format.encoding,
              data_format.schema), 'mimeType')
Example #3
0
 def set_format_validator(supported_format):
     if not supported_format.validate or \
        supported_format.validate == emptyvalidator:
         supported_format.validate =\
             get_validator(supported_format.mime_type)
     return supported_format
Example #4
0
def get_data_format(mime_type):
    return Format(mime_type=mime_type, validate=get_validator(mime_type))
Example #5
0
 def test_validator(self):
     assert self.complex_out.validator == get_validator('application/json')