コード例 #1
0
ファイル: v_perf.py プロジェクト: DIRACGrid/DIRAC
 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
コード例 #2
0
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"]
コード例 #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
コード例 #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)
コード例 #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)
コード例 #6
0
ファイル: v_perf.py プロジェクト: DIRACGrid/DIRAC
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"
コード例 #7
0
ファイル: Client.py プロジェクト: TaykYoku/DIRAC
    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
コード例 #8
0
def test_echo(data):
    service = RPCClient("Framework/User")

    assert service.echo(data)["Value"] == data
コード例 #9
0
def test_ping():
    service = RPCClient("Framework/User")

    assert service.ping()["OK"]
コード例 #10
0
def test_unknown_method():
    service = RPCClient("Framework/User")

    unknownmethod = service.ThisMethodMayNotExist()
    assert unknownmethod["OK"] is False
    assert unknownmethod["Message"] == "Unknown method ThisMethodMayNotExist"
コード例 #11
0
ファイル: v_perf.py プロジェクト: DIRACGrid/DIRAC
 def __init__(self):
     self.client = RPCClientSelector("Framework/User", timeout=30)
     return