Beispiel #1
0
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from smartrpyc.client import Client

c = Client("tcp://127.0.0.1:5555")
map(c.log, ["test"] * 1000)
Beispiel #2
0
    def test_with_client(self):
        addr = get_random_ipc_socket()
        with utils.TestingServer(methods=self.get_methods(), addresses=addr):
            client = Client(addr)
            assert client.method1() == 'Hello, world!'

            with pytest.raises(RemoteException):
                client.method1('this', 'does not', 'accept arguments!')

            assert client.method2(u'WORLD') == u'Hello, WORLD!'
            assert client.method2(name=u'WORLD') == u'Hello, WORLD!'
            assert client.method2(name=u'Ẅøřłđ') == u'Hello, Ẅøřłđ!'

            assert client.method3('Hi', 'man') == 'Hi, man!'
            assert client.method3(greeting='Hi', name='man') == 'Hi, man!'
            assert client.method3(greeting='Hi') == 'Hi, world!'

            with pytest.raises(RemoteException):
                client.method3('HELLO', greeting='Hi')

            assert client.get_list() == ['this', 'is', 'a', 'list']
            assert client.get_dict() == {'this': 'is', 'a': 'dict'}

            with pytest.raises(RemoteException):
                client.raise_value_error()

            ## Ok, the method doesn't exist, no big deal..
            with pytest.raises(RemoteException):
                client.no_such_method()

            client.method1()  # The server must still be alive here..
Beispiel #3
0
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from smartrpyc.client import Client

c = Client("tcp://127.0.0.1:5555")
c.log("test")