def test_ZMQ_proxy_client():
    """
    Checks the client proxy class. The client proxy should obtain the
    exposed function names of the named object on the server, the doc
    strings for each of those, and should be able to call the functions
    as if they were local.
    """

    foo_proxy = ZMQJSONProxyClient(ctx, 'foo', url)

    assert 'Cat process' in foo_proxy.cat.__doc__
    cat_ret = foo_proxy.cat()
    assert cat_ret == "meow"

    assert 'Dog process' in foo_proxy.dog.__doc__
    dog_ret = foo_proxy.dog()
    assert dog_ret == "woof"

    assert 'Frog process' in foo_proxy.frog.__doc__
    frog_ret = foo_proxy.frog()
    assert frog_ret == "rivet!"

    assert 'Adds two' in foo_proxy.add_two.__doc__
    add_ret = foo_proxy.add_two(2, 2)
    assert add_ret == 4
    add_ret = foo_proxy.add_two(2, y=3)
    assert add_ret == 5
    add_ret = foo_proxy.add_two(y=3, x=4)
    assert add_ret == 7
def test_ZMQ_proxy_client():
    """
    Checks the client proxy class. The client proxy should obtain the
    exposed function names of the named object on the server, the doc
    strings for each of those, and should be able to call the functions
    as if they were local.
    """

    foo_proxy = ZMQJSONProxyClient(ctx, 'foo', url)

    assert 'Cat process' in foo_proxy.cat.__doc__
    cat_ret = foo_proxy.cat()
    assert cat_ret == "meow"

    assert 'Dog process' in foo_proxy.dog.__doc__
    dog_ret = foo_proxy.dog()
    assert dog_ret == "woof"

    assert 'Frog process' in foo_proxy.frog.__doc__
    frog_ret = foo_proxy.frog()
    assert frog_ret == "rivet!"

    assert 'Adds two' in foo_proxy.add_two.__doc__
    add_ret = foo_proxy.add_two(2, 2)
    assert add_ret == 4
    add_ret = foo_proxy.add_two(2, y = 3)
    assert add_ret == 5
    add_ret = foo_proxy.add_two(y = 3, x = 4)
    assert add_ret == 7
示例#3
0
    def __init__(self, ctx, name, url = None):
        if url:
            self.url = url
        else:
            dibas_dir = os.getenv('DIBAS_DIR')

            if dibas_dir == None:
                raise Exception("'DIBAS_DIR' is not set!")

            config_file = dibas_dir + '/etc/config/dibas.conf'
            config = ConfigParser.ConfigParser()
            config.readfp(open(config_file))
            playerhost = config.get(name.upper(), 'hpchost').lstrip('"').rstrip('"')
            playerport = config.getint(name.upper(), 'player_port')
            self.url = "tcp://%s:%i" % (playerhost, playerport)

        ZMQJSONProxyClient.__init__(self, ctx, 'bank', self.url, time_out = 180)
        self.roach = ZMQJSONProxyClient(ctx, 'bank.roach', self.url)
        self.valon = ZMQJSONProxyClient(ctx, 'bank.valon', self.url)
示例#4
0
    def __init__(self, ctx, name, url = None):
        if url:
            self.url = url
        else:
            dibas_dir = os.getenv('DIBAS_DIR')

            if dibas_dir == None:
                raise Exception("'DIBAS_DIR' is not set!")

            config_file = dibas_dir + '/etc/config/dibas.conf'
            config = ConfigParser.ConfigParser()
            config.readfp(open(config_file))
            playerhost = config.get(name.upper(), 'hpchost').lstrip('"').rstrip('"')
            playerport = config.getint(name.upper(), 'player_port')
            self.url = "tcp://%s:%i" % (playerhost, playerport)

        ZMQJSONProxyClient.__init__(self, ctx, 'bank', self.url, time_out = 180)
        self.roach = ZMQJSONProxyClient(ctx, 'bank.roach', self.url)
        self.valon = ZMQJSONProxyClient(ctx, 'bank.valon', self.url)