Beispiel #1
0
 def __init__(self):
     # If we want we can force to use another service name (testing multiple services for example)
     if len(sys.argv) > 2:
         self.client = RPCClientSelector(sys.argv[2])
     else:
         self.client = RPCClientSelector("Framework/User")
     return
def test_authorization():
    service = RPCClient("Framework/User")

    authorisation = service.unauthorized(
    )  # In the handler this method have no allowed properties
    assert authorisation["OK"] is False
    assert authorisation["Message"] == S_ERROR(ENOAUTH,
                                               "Unauthorized query")["Message"]
Beispiel #3
0
def test_urls_used_by_TornadoClient(config, client):
    # We can't directly get url because they are randomized but we can check if we have right number of URL

    nbOfUrl = client[0]
    component_service = client[1]
    clientSelected = RPCClientSelector(component_service)
    # Little hack to get the private attribute
    assert nbOfUrl == clientSelected._TornadoBaseClient__nbOfUrls
Beispiel #4
0
def test_error(component_service, config):
    """
    In any other cases (including error cases) it must return RPCClient by default
    This test is NOT testing if RPCClient handle the errors
    It just test that we get RPCClient and not Tornadoclient
    """
    clientSelected = RPCClientSelector(component_service)
    assert isinstance(clientSelected, RPCClient)
Beispiel #5
0
def test_selection_when_using_RPCClientSelector(client, config):
    """
    One way to call service is to use RPCClient or TornadoClient
    If service is HTTPS, it must return client who work with tornado (TornadoClient)
    else it must return the RPCClient
    """
    clientWanted = client[0]
    component_service = client[1]
    clientSelected = RPCClientSelector(component_service)
    assert isinstance(clientSelected, clientWanted)
Beispiel #6
0
class Transaction(object):
    def __init__(self):
        # If we want we can force to use another service name (testing multiple services for example)
        if len(sys.argv) > 2:
            self.client = RPCClientSelector(sys.argv[2])
        else:
            self.client = RPCClientSelector("Framework/User")
        return

    def run(self):
        assert self.client.ping()["OK"], "error"
Beispiel #7
0
    def _getRPC(self, rpc=None, url="", timeout=None):
        """Return an RPCClient object constructed following the attributes.

        :param rpc: if set, returns this object
        :param url: url of the service. If not set, use self.serverURL
        :param timeout: timeout of the call. If not given, self.timeout will be used
        """
        if not rpc:
            if not url:
                url = self.serverURL

            if not timeout:
                timeout = self.timeout

            self.__kwargs["timeout"] = timeout
            rpc = RPCClientSelector(url, httpsClient=self.httpsClient, **self.__kwargs)
        return rpc
def test_echo(data):
    service = RPCClient("Framework/User")

    assert service.echo(data)["Value"] == data
def test_ping():
    service = RPCClient("Framework/User")

    assert service.ping()["OK"]
def test_unknown_method():
    service = RPCClient("Framework/User")

    unknownmethod = service.ThisMethodMayNotExist()
    assert unknownmethod["OK"] is False
    assert unknownmethod["Message"] == "Unknown method ThisMethodMayNotExist"
Beispiel #11
0
 def __init__(self):
     self.client = RPCClientSelector("Framework/User", timeout=30)
     return