def test_createMoving_1(self): """ test creating transformation """ tSE = "Target-SRM" sSE = "Source-SRM" prodID = 12345 dType = "DNS" module_name = "ILCDIRAC.ILCTransformationSystem.Utilities.MovingTransformation" trmodule = "DIRAC.TransformationSystem.Client.Transformation.Transformation" with patch(trmodule+".getTransformation", new=Mock(return_value=S_OK({}))), \ patch(trmodule+".addTransformation", new=Mock(return_value=S_OK())), \ patch(trmodule+"._Transformation__setSE", new=Mock(return_value=S_OK())), \ patch("%s.TransformationClient" % module_name, new=self.tMock ): ret = createMovingTransformation(tSE, sSE, prodID, dType) self.assertTrue(ret['OK'], ret.get('Message', ""))
def createMovingTransformation( self, meta, prodType ): """ create moving transformations for output files """ sourceSE = self.outputSE targetSE = self.finalOutputSE prodID = meta['ProdID'] try: dataTypes = { 'MCReconstruction': ('DST', 'REC'), 'MCReconstruction_Overlay': ('DST', 'REC'), 'MCSimulation': ('SIM',), 'MCGeneration': ('GEN',), }[prodType] except KeyError: raise RuntimeError( "ERROR creating MovingTransformation" + repr(prodType) + "unknown" ) if not any( getattr( self._flags, "move%s" % dataType.capitalize() ) for dataType in dataTypes ): gLogger.notice( "*"*80 + "\nNot creating moving transformation for prodID: %s, %s " % (meta['ProdID'], prodType ) ) return from ILCDIRAC.ILCTransformationSystem.Utilities.MovingTransformation import createMovingTransformation for dataType in dataTypes: if getattr( self._flags, "move%s" % dataType.capitalize() ): gLogger.notice( "*"*80 + "\nCreating moving transformation for prodID: %s, %s, %s " % (meta['ProdID'], prodType, dataType ) ) createMovingTransformation( targetSE, sourceSE, prodID, dataType )
def test_createMoving_SEFail_2(self): """ test creating transformation """ tSE = "Target-SRM" sSE = "Source-SRM" prodID = 12345 dType = "DNS" module_name = "ILCDIRAC.ILCTransformationSystem.Utilities.MovingTransformation" trmodule = "DIRAC.TransformationSystem.Client.Transformation.Transformation" with patch(trmodule+".getTransformation", new=Mock(return_value=S_OK({}))), \ patch(trmodule+".addTransformation", new=Mock(return_value=S_OK())), \ patch(trmodule+"._Transformation__setSE", new=Mock(side_effect=(S_ERROR(), S_ERROR()))), \ patch("%s.TransformationClient" % module_name, new=self.tMock ): ret = createMovingTransformation(tSE, sSE, prodID, dType) self.assertFalse(ret['OK'], str(ret)) self.assertIn("SourceSE not valid", ret['Message'])
def test_createMoving_createTrafoFail_(self): """ test creating transformation """ tSE = "Target-SRM" sSE = "Source-SRM" prodID = 12345 dType = "DNS" self.tClientMock.createTransformationInputDataQuery.return_value = S_ERROR( "Failed to create IDQ") module_name = "ILCDIRAC.ILCTransformationSystem.Utilities.MovingTransformation" trmodule = "DIRAC.TransformationSystem.Client.Transformation.Transformation" with patch(trmodule+".getTransformation", new=Mock(return_value=S_OK({}))), \ patch(trmodule+".addTransformation", new=Mock(return_value=S_OK())), \ patch(trmodule+"._Transformation__setSE", new=Mock(return_value=S_OK())), \ patch("%s.TransformationClient" % module_name, new=self.tMock ): ret = createMovingTransformation(tSE, sSE, prodID, dType) self.assertFalse(ret['OK'], str(ret)) self.assertIn("Failed to create transformation:Failed to create IDQ", ret['Message'])