def initialize(self): """ LHCb defaults """ DIRACTransformationAgent.initialize(self) self.pluginLocation = self.am_getOption( 'PluginLocation', 'LHCbDIRAC.TransformationSystem.Agent.TransformationPlugin') self.workDirectory = self.am_getWorkDirectory() self.debug = self.am_getOption('verbosePlugin', False) return S_OK()
def test__getTransformationFiles(mocker, transDict, getTFiles, expected): mocker.patch( "DIRAC.TransformationSystem.Agent.TransformationAgent.AgentModule", side_effect=mockAM) tc_mock.getTransformationFiles.return_value = getTFiles res = TransformationAgent()._getTransformationFiles( transDict, {"TransformationClient": tc_mock}) assert res["OK"] == expected
def setUp( self ): self.mockTC = Mock() import DIRAC.Core.Base.AgentModule as moduleMocked moduleMocked.AgentModule = mockAgentModule from DIRAC.TransformationSystem.Agent.TransformationAgent import TransformationAgent # import DIRAC.TransformationSystem.Agent.TransformationAgent as mockedModule # mockedModule.TransformationAgent.__bases__ = ( mockAgentModule, mockedModule.TransformationAgent.__bases__[1] ) self.ta = TransformationAgent( 'ta', 'ta' ) self.ta.transfClient = self.mockTC
def _getClients(self): """ returns the clients used in the threads """ res = DIRACTransformationAgent._getClients(self) threadTransformationClient = TransformationClient() threadRMClient = ResourceManagementClient() threadBkk = BookkeepingClient() res.update({ 'TransformationClient': threadTransformationClient, 'ResourceManagementClient': threadRMClient, 'BookkeepingClient': threadBkk }) return res
def setUp( self ): self.mockAM = MagicMock() self.tmab_m = importlib.import_module( 'DIRAC.TransformationSystem.Agent.TaskManagerAgentBase' ) self.tmab_m.AgentModule = self.mockAM self.tmab_m.FileReport = MagicMock() self.tmab = TaskManagerAgentBase() self.tmab.log = gLogger self.tmab.am_getOption = self.mockAM self.tmab.log.setLevel( 'DEBUG' ) self.ta_m = importlib.import_module( 'DIRAC.TransformationSystem.Agent.TransformationAgent' ) self.ta_m.AgentModule = self.mockAM self.ta = TransformationAgent() self.ta.log = gLogger self.ta.am_getOption = self.mockAM self.tmab.log.setLevel( 'DEBUG' ) self.tc_mock = MagicMock() self.tm_mock = MagicMock()
tmMockSubmitTransformationTasksReturnValue, tmMockUpdateDBAfterTaskSubmissionReturnValue, expected): tc_mock.getTasksToSubmit.return_value = tcMockGetTasksToSubmitReturnValue tm_mock.prepareTransformationTasks.return_value = tmMockPrepareTransformationTasksReturnValue tm_mock.submitTransformationTasks.return_value = tmMockSubmitTransformationTasksReturnValue tm_mock.updateDBAfterTaskSubmission.return_value = tmMockUpdateDBAfterTaskSubmissionReturnValue res = tmab.submitTasks(transIDOPBody, clients) assert res['OK'] == expected # TransformationAgent ta_m = importlib.import_module( 'DIRAC.TransformationSystem.Agent.TransformationAgent') ta_m.AgentModule = mockAM ta = TransformationAgent() ta.log = gLogger ta.am_getOption = mockAM goodFiles = { 'OK': True, 'Value': [{ 'ErrorCount': 1, 'FileID': 17990660, 'InsertedTime': datetime.datetime(2012, 3, 15, 17, 5, 50), 'LFN': '/00012574_00000239_1.charmcompleteevent.dst', 'LastUpdate': datetime.datetime(2012, 3, 16, 23, 43, 26), 'RunNumber': 90269, 'Status': 'Unused', 'TargetSE': 'Unknown',