Exemplo n.º 1
0
def test__requestProxyFromProxyManager(mocker, mockGCReplyInput,
                                       mockPMReplyInput, expected):
    """ Testing JobAgent()._requestProxyFromProxyManager()
  """

    mockGCReply.return_value = mockGCReplyInput
    mockPMReply.return_value = mockPMReplyInput

    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobAgent.AgentModule.__init__")
    mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.AgentModule",
                 side_effect=mockAM)
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobAgent.gConfig.getValue",
        side_effect=mockGCReply)
    module_str = "DIRAC.WorkloadManagementSystem.Agent.JobAgent.gProxyManager.getPayloadProxyFromDIRACGroup"
    mocker.patch(module_str, side_effect=mockPMReply)

    jobAgent = JobAgent('Test', 'Test1')

    ownerDN = 'DIRAC'
    ownerGroup = 'DIRAC'

    jobAgent.log = gLogger
    jobAgent.log.setLevel('DEBUG')

    result = jobAgent._requestProxyFromProxyManager(ownerDN, ownerGroup)

    assert result['OK'] == expected['OK']

    if result['OK']:
        assert result['Value'] == expected['Value']

    else:
        assert result['Message'] == expected['Message']
Exemplo n.º 2
0
def test__requestProxyFromProxyManager(mocker, mockGCReply, mockPMReply,
                                       expected):
    """Testing JobAgent()._requestProxyFromProxyManager()"""
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobAgent.AgentModule.__init__")
    mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.AgentModule")
    mocker.patch(
        "DIRAC.WorkloadManagementSystem.Agent.JobAgent.gConfig.getValue",
        return_value=mockGCReply)
    module_str = "DIRAC.WorkloadManagementSystem.Agent.JobAgent.gProxyManager.getPayloadProxyFromDIRACGroup"
    mocker.patch(module_str, return_value=mockPMReply)

    jobAgent = JobAgent("Test", "Test1")

    ownerDN = "DIRAC"
    ownerGroup = "DIRAC"

    jobAgent.log = gLogger
    jobAgent.log.setLevel("DEBUG")

    result = jobAgent._requestProxyFromProxyManager(ownerDN, ownerGroup)

    assert result["OK"] == expected["OK"]

    if result["OK"]:
        assert result["Value"] == expected["Value"]

    else:
        assert result["Message"] == expected["Message"]