def test_validate_result_object_method(): class FooClass: def foo(self, one, two): return "bar" f = FooClass().foo assert validate_args(Request("f", ["one", "two"], NOID), NOCONTEXT, f) == Right(f)
def test_validate_result_positionals_not_passed(): assert validate_args( Request("f", {"foo": "bar"}, NOID), NOCONTEXT, lambda x: None ) == Left( ErrorResult( ERROR_INVALID_PARAMS, "Invalid params", "missing a required argument: 'x'" ) )
def test_validate_result_no_arguments_too_many_positionals(): assert validate_args(Request("f", ["foo"], NOID), NOCONTEXT, lambda: None) == Left( ErrorResult( code=ERROR_INVALID_PARAMS, message="Invalid params", data="too many positional arguments", ) )
def test_validate_args(): assert validate_args(Request("ping", ["foo"], 1), NOCONTEXT, ping) == Left( ErrorResult( ERROR_INVALID_PARAMS, "Invalid params", "too many positional arguments" ) )
def test_validate_args(): assert validate_args(Request("ping", [], 1), NOCONTEXT, ping) == Right(ping)
def test_validate_result_keywords(): f = lambda **kwargs: None assert validate_args(Request("f", {"foo": "bar"}, NOID), NOCONTEXT, f) == Right(f)
def test_validate_result_positionals(): f = lambda x: None assert validate_args(Request("f", [1], NOID), NOCONTEXT, f) == Right(f)
def test_validate_result_no_arguments(): f = lambda: None assert validate_args(Request("f", [], NOID), NOCONTEXT, f) == Right(f)