Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Aug 3, 2021
1 parent acd2385 commit 9bf42fa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,23 @@ def test__getJDLParameters(mocker):
assert result['Value']['Tags'] == ['16Processors', 'MultiProcessor']


@pytest.mark.parametrize("mockJMInput, expected", [({'OK': True}, {'OK': True, 'Value': 'Job Rescheduled'}), ({
'OK': False, 'Message': "Test"}, {'OK': True, 'Value': 'Problem Rescheduling Job'})])
@pytest.mark.parametrize(
"mockJMInput, expected",
[
({"OK": True}, {"OK": True, "Value": "Problem Rescheduling Job"}),
(
{"OK": False, "Message": "Test"},
{"OK": True, "Value": "Problem Rescheduling Job"},
),
],
)
def test__rescheduleFailedJob(mocker, mockJMInput, expected):
""" Testing JobAgent()._rescheduleFailedJob()
"""

mockJM.return_value = mockJMInput

mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.AgentModule.__init__")
mocker.patch(
"DIRAC.WorkloadManagementSystem.Client.JobManagerClient.JobManagerClient.rescheduleJob",
side_effect=mockJM,
)

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

Expand All @@ -103,16 +107,26 @@ def test__rescheduleFailedJob(mocker, mockJMInput, expected):


@pytest.mark.parametrize(
"mockGCReplyInput, mockPMReplyInput, expected", [
(True, {
'OK': True, 'Value': 'Test'}, {
'OK': True, 'Value': 'Test'}), (True, {
'OK': False, 'Message': 'Test'}, {
'OK': False, 'Message': 'Failed to setup proxy: Error retrieving proxy'}), (False, {
'OK': True, 'Value': 'Test'}, {
'OK': False, 'Message': 'Invalid Proxy'}), (False, {
'OK': False, 'Message': 'Test'}, {
'OK': False, 'Message': 'Invalid Proxy'})])
"mockGCReplyInput, mockPMReplyInput, expected",
[
(True, {"OK": True, "Value": "Test"}, {"OK": True, "Value": "Test"}),
(
True,
{"OK": False, "Message": "Test"},
{"OK": False, "Message": "Failed to setup proxy: Error retrieving proxy"},
),
(
False,
{"OK": True, "Value": "Test"},
{"OK": False, "Message": "Invalid Proxy"},
),
(
False,
{"OK": False, "Message": "Test"},
{"OK": False, "Message": "Invalid Proxy"},
),
],
)
def test__setupProxy(mocker, mockGCReplyInput, mockPMReplyInput, expected):
""" Testing JobAgent()._setupProxy()
"""
Expand Down Expand Up @@ -162,16 +176,22 @@ def test__getCPUWorkLeft(mocker):


@pytest.mark.parametrize(
"mockGCReplyInput, mockPMReplyInput, expected", [
(True, {
'OK': True, 'Value': 'Test'}, {
'OK': True, 'Value': 'Test'}), (True, {
'OK': False, 'Message': 'Test'}, {
'OK': False, 'Message': 'Error retrieving proxy'}), (False, {
'OK': True, 'Value': 'Test'}, {
'OK': True, 'Value': 'Test'}), (False, {
'OK': False, 'Message': 'Test'}, {
'OK': False, 'Message': 'Error retrieving proxy'})])
"mockGCReplyInput, mockPMReplyInput, expected",
[
(True, {"OK": True, "Value": "Test"}, {"OK": True, "Value": "Test"}),
(
True,
{"OK": False, "Message": "Test"},
{"OK": False, "Message": "Error retrieving proxy"},
),
(False, {"OK": True, "Value": "Test"}, {"OK": True, "Value": "Test"}),
(
False,
{"OK": False, "Message": "Test"},
{"OK": False, "Message": "Error retrieving proxy"},
),
],
)
def test__requestProxyFromProxyManager(mocker, mockGCReplyInput, mockPMReplyInput, expected):
""" Testing JobAgent()._requestProxyFromProxyManager()
"""
Expand Down Expand Up @@ -220,8 +240,10 @@ def test__checkInstallSoftware(mocker):
assert result['Value'] == 'Job has no software installation requirement'


@pytest.mark.parametrize("mockJWInput, expected", [(
{'OK': False, 'Message': 'Test'}, {'OK': False, 'Message': 'Test'})])
@pytest.mark.parametrize(
"mockJWInput, expected",
[({'OK': False, 'Message': 'Test'}, {'OK': False, 'Message': 'Test'})]
)
def test_submitJob(mocker, mockJWInput, expected):
""" Testing JobAgent()._submitJob()
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from DIRAC import gLogger
from DIRAC.Core.Tornado.Server.TornadoService import TornadoService
from DIRAC.WorkloadManagementSystem.Service.JobMonitoringandler import JobMonitoringHandlerMixin
from DIRAC.WorkloadManagementSystem.Service.JobMonitoringHandler import JobMonitoringHandlerMixin


sLog = gLogger.getSubLogger(__name__)
Expand Down

0 comments on commit 9bf42fa

Please sign in to comment.