Ejemplo n.º 1
0
async def test_method_registry_view():
    registry = dispatcher.MethodRegistry()
    validator = validators.BaseValidator()
    validator_args = {'arg': 'value'}

    class MethodView(ViewMixin):
        @validator.validate(**validator_args)
        def method1(self):
            pass

        @validator.validate(**validator_args)
        async def method2(self, param1):
            assert param1 == 'param1'

    registry.view(MethodView, prefix='view')

    assert registry['view.method1'].validator == validator
    assert registry['view.method1'].validator_args == validator_args
    assert registry['view.method2'].validator == validator
    assert registry['view.method2'].validator_args == validator_args
Ejemplo n.º 2
0
def test_validation_exclude_error(dyn_method, exclude, params):
    validator = validators.BaseValidator()

    with pytest.raises(validators.ValidationError):
        validator.validate_method(dyn_method, params, exclude=exclude)
Ejemplo n.º 3
0
def test_validation_exclude_success(dyn_method, exclude, params):
    validator = validators.BaseValidator()
    validator.validate_method(dyn_method, params, exclude=exclude)
Ejemplo n.º 4
0
def test_validation_success(dyn_method, params):
    validator = validators.BaseValidator()
    validator.validate_method(dyn_method, params)