Not possible to test Webargs validation
When using validation or custom fields, it is not possible to test "validation" or "_deserialize" functions. For example:
class Checkpoint(fields.String):
"""Field that takes a string and validates against current available
models at config.MODELS_PATH.
"""
def _deserialize(self, value, attr, data, **kwargs):
if value not in utils.ls_models():
raise ValidationError(f"Checkpoint `{value}` not found.")
return str(config.MODELS_PATH / value)
Does not run when on testing you can only call "api.predict". Or:
batch_size = fields.Integer(
metadata={
"description": "Number of samples per batch.",
},
required=False,
validate=validate.Range(min=1),
)
Cannot test that "api.predict" returns validation error when batch_size is lower than 1.