def test_ProviderBase_list_methods_functions(server): """Test that functions are returned as well""" pb = reddel_server.ProviderBase(server) def foo(): pass # pragma: nocover pb.func = foo assert "func" in pb.list_methods()
def test_Providerbase_help(server): """Test that help returns the docstring.""" pb = reddel_server.ProviderBase(server) def foo(): """Test docstring""" pass # pragma: nocover pb.foo = foo assert pb.help("foo") == "Test docstring"
def pbwithvalidator(server): """A provider base with foo as test function. The validator on foo only marks the source ``valid`` as valid. """ pb = reddel_server.ProviderBase(server) def foo(): pass # pragma: nocover def validator(src): if "valid" != src.dumps(): raise reddel_server.ValidationException foo.validators = [validator] pb.func = foo return pb
def test_ProviderBase_get_method(server): """Test _get_method returns the methods.""" pb = reddel_server.ProviderBase(server) methods = pb.list_methods() expected = [getattr(pb, m) for m in pb.list_methods()] assert [pb._get_method(m) for m in pb.list_methods()]
def test_ProviderBase_list_methods_lambda(server): """Test that lambdas are returned as well""" pb = reddel_server.ProviderBase(server) pb.lambdafunc = lambda: True # pragma: nocover assert "lambdafunc" in pb.list_methods()
def test_ProviderBase_list_methods(server): """Test all expected methods are listed""" pb = reddel_server.ProviderBase(server) expected = ["echo", "help", "list_methods", "reddel_version"] assert pb.list_methods() == expected
def test_ProviderBase_str(server): pb = reddel_server.ProviderBase(server) assert str(pb) == "<ProviderBase at {0}>".format(hex(id(pb)))
def test_ProviderBase_repr(server): pb = reddel_server.ProviderBase(server) assert repr(pb) == "ProviderBase({0!r})".format(server)
def test_ProviderBase_echo(server): expected = "test this" assert reddel_server.ProviderBase(server).echo(expected) is expected
def test_ProviderBase_reddel_version(server): assert reddel_server.ProviderBase( server).reddel_version() == reddel_server.__version__