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"]
def test_configurationAutoUpdate(value1, value2):
    """
    Test if service refresh his configuration. It sent a random value to the CS
    and check if Service can return it.

    """
    csapi = CSAPI()

    # SETTING FIRST VALUE
    csapi.modifyValue("/DIRAC/Configuration/TestUpdateValue", value1)
    csapi.commitChanges()

    # Wait for automatic refresh (+1 to be sure that request is done)
    time.sleep(gConfigurationData.getPropagationTime() + 1)
    RPCClient("Framework/User").getTestValue()
    assert RPCClient("Framework/User").getTestValue()["Value"] == value1

    # SETTING SECOND VALUE
    csapi.modifyValue("/DIRAC/Configuration/TestUpdateValue", value2)
    csapi.commitChanges()
    time.sleep(gConfigurationData.getPropagationTime() + 1)
    assert RPCClient("Framework/User").getTestValue()["Value"] == value2
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"