예제 #1
0
class RequestTaskTests( unittest.TestCase ):
  """
  .. class:: RequestTaskTests

  """

  def setUp( self ):
    """ test case set up """
    self.handlersDict = { "ForwardDISET" : "DIRAC/RequestManagementSystem/private/ForwardDISET" }
    self.req = Request()
    self.req.RequestName = "foobarbaz"
    self.req.OwnerGroup = "dirac_user"
    self.req.OwnerDN = "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=cibak/CN=605919/CN=Krzysztof Ciba"
    self.op = Operation( { "Type": "ForwardDISET", "Arguments" : "tts10:helloWorldee" } )
    self.req.addOperation( self.op )
    self.task = None  

  def tearDown( self ):
    """ test case tear down """
    del self.req
    del self.op
    del self.task

  def testAPI( self ):
    """ test API """
    self.task = RequestTask( self.req.toXML()["Value"], self.handlersDict )
    self.task.requestClient = Mock( return_value = Mock(spec=RequestClient) ) 
    self.task.requestClient().updateRequest = Mock()
    self.task.requestClient().updateRequest.return_value = { "OK" : True, "Value" : None }    
    ret = self.task()
    self.assertEqual( ret["OK"], True , "call failed")
예제 #2
0
    def testAPI(self):
        """ test API
    """
        rt = importlib.import_module(
            'DIRAC.RequestManagementSystem.private.RequestTask')
        rt.gMonitor = MagicMock()
        rt.Operations = self.mockOps
        rt.CS = MagicMock()

        self.task = RequestTask(self.req.toJSON()["Value"],
                                self.handlersDict,
                                'csPath',
                                'RequestManagement/RequestExecutingAgent',
                                requestClient=self.mockRC)
        self.task.requestClient = Mock(return_value=Mock(spec=ReqClient))
        self.task.requestClient().updateRequest = Mock()
        self.task.requestClient().updateRequest.return_value = {
            "OK": True,
            "Value": None
        }
        ret = self.task()
        self.assertEqual(ret["OK"], True, "call failed")

        ret = self.task.setupProxy()
        print(ret)
예제 #3
0
 def testAPI( self ):
   """ test API """
   self.task = RequestTask( self.req.toXML()["Value"], self.handlersDict )
   self.task.requestClient = Mock( return_value = Mock(spec=RequestClient) ) 
   self.task.requestClient().updateRequest = Mock()
   self.task.requestClient().updateRequest.return_value = { "OK" : True, "Value" : None }    
   ret = self.task()
   self.assertEqual( ret["OK"], True , "call failed")
예제 #4
0
    def __init__(self, *args, **kwargs):
        """c'tor

    :param self: self reference
    """
        RequestTask.__init__(self, *args, **kwargs)
        self.setRequestType("register")
        self.addOperationAction("registerFile", self.registerFile)
예제 #5
0
  def __init__( self, *args, **kwargs ):
    """c'tor

    :param self: self reference
    """
    RequestTask.__init__( self, *args, **kwargs )
    self.setRequestType( "register" )
    self.addOperationAction( "registerFile", self.registerFile )
예제 #6
0
class RequestTaskTests(unittest.TestCase):
    """
    .. class:: RequestTaskTests

    """

    def setUp(self):
        """test case set up"""
        self.handlersDict = {"ForwardDISET": "DIRAC/RequestManagementSystem/private/ForwardDISET"}
        self.req = Request()
        self.req.RequestName = "foobarbaz"
        self.req.OwnerGroup = "lhcb_user"
        self.req.OwnerDN = "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=chaen/CN=705305/CN=Christophe Haen"
        self.op = Operation({"Type": "ForwardDISET", "Arguments": "tts10:helloWorldee"})
        self.req.addOperation(self.op)
        self.task = None
        self.mockRC = MagicMock()

        self.mockObjectOps = MagicMock()
        self.mockObjectOps.getSections.return_value = {"OK": True, "Value": ["DataProcessing", "DataManager"]}
        self.mockObjectOps.getOptionsDict.return_value = {
            "OK": True,
            "Value": {"Group": "lhcb_user", "User": "******"},
        }
        self.mockOps = MagicMock()
        self.mockOps.return_value = self.mockObjectOps

    def tearDown(self):
        """test case tear down"""
        del self.req
        del self.op
        del self.task

    def testAPI(self):
        """test API"""
        rt = importlib.import_module("DIRAC.RequestManagementSystem.private.RequestTask")
        rt.gMonitor = MagicMock()
        rt.Operations = self.mockOps
        rt.CS = MagicMock()

        self.task = RequestTask(
            self.req.toJSON()["Value"],
            self.handlersDict,
            "csPath",
            "RequestManagement/RequestExecutingAgent",
            requestClient=self.mockRC,
        )
        self.task.requestClient = Mock(return_value=Mock(spec=ReqClient))
        self.task.requestClient().updateRequest = Mock()
        self.task.requestClient().updateRequest.return_value = {"OK": True, "Value": None}
        ret = self.task()
        self.assertEqual(ret["OK"], True, "call failed")

        ret = self.task.setupProxy()
        print(ret)
예제 #7
0
class RequestTaskTests( unittest.TestCase ):
  """
  .. class:: RequestTaskTests

  """

  def setUp( self ):
    """ test case set up """
    self.handlersDict = { "ForwardDISET" : "DIRAC/RequestManagementSystem/private/ForwardDISET" }
    self.req = Request()
    self.req.RequestName = "foobarbaz"
    self.req.OwnerGroup = "lhcb_user"
    self.req.OwnerDN = "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=chaen/CN=705305/CN=Christophe Haen"
    self.op = Operation( { "Type": "ForwardDISET", "Arguments" : "tts10:helloWorldee" } )
    self.req.addOperation( self.op )
    self.task = None
    self.mockRC = MagicMock()

    self.mockObjectOps = MagicMock()
    self.mockObjectOps.getSections.return_value = {'OK': True,
                                                   'Value': ['DataProcessing',
                                                             'DataManager']}
    self.mockObjectOps.getOptionsDict.return_value = {'OK': True,
                                                      'Value': {'Group': 'lhcb_user', 'User': '******'}}
    self.mockOps = MagicMock()
    self.mockOps.return_value = self.mockObjectOps


  def tearDown( self ):
    """ test case tear down """
    del self.req
    del self.op
    del self.task

  def testAPI( self ):
    """ test API
    """
    rt = importlib.import_module( 'DIRAC.RequestManagementSystem.private.RequestTask' )
    rt.gMonitor = MagicMock()
    rt.Operations = self.mockOps
    rt.CS = MagicMock()

    self.task = RequestTask( self.req.toJSON()["Value"], self.handlersDict, 'csPath', 'RequestManagement/RequestExecutingAgent',
                             requestClient = self.mockRC )
    self.task.requestClient = Mock( return_value = Mock( spec = ReqClient ) )
    self.task.requestClient().updateRequest = Mock()
    self.task.requestClient().updateRequest.return_value = { "OK" : True, "Value" : None }
    ret = self.task()
    self.assertEqual( ret["OK"], True , "call failed" )

    ret = self.task.setupProxy()
    print ret
예제 #8
0
  def __init__( self, *args, **kwargs ):
    """c'tor

    :param self: self reference
    :param list args: args list
    :param dict kwargs: args dict
    """
    ## parent class init
    RequestTask.__init__( self, *args, **kwargs )
    ## set request type
    self.setRequestType( "transfer" )
    ## operation handlers
    self.addOperationAction( "putAndRegister", self.putAndRegister )
    self.addOperationAction( "replicateAndRegister", self.replicateAndRegister )
예제 #9
0
    def __init__(self, *args, **kwargs):
        """c'tor

    :param self: self reference
    :param tuple args: anonymouse args tuple
    :param dict kwagrs: named args dict
    """
        RequestTask.__init__(self, *args, **kwargs)
        self.setRequestType("removal")
        # # operation handlers physicalRemoval
        self.addOperationAction("physicalRemoval", self.physicalRemoval)
        self.addOperationAction("removeFile", self.removeFile)
        self.addOperationAction("replicaRemoval", self.replicaRemoval)
        self.addOperationAction("reTransfer", self.reTransfer)
예제 #10
0
  def __init__( self, *args, **kwargs ):
    """c'tor

    :param self: self reference
    :param tuple args: anonymouse args tuple
    :param dict kwagrs: named args dict
    """
    RequestTask.__init__( self, *args, **kwargs )
    self.setRequestType( "removal" )
    # # operation handlers physicalRemoval
    self.addOperationAction( "physicalRemoval", self.physicalRemoval )
    self.addOperationAction( "removeFile", self.removeFile )
    self.addOperationAction( "replicaRemoval", self.replicaRemoval )
    self.addOperationAction( "reTransfer", self.reTransfer )
예제 #11
0
    def __init__(self, *args, **kwargs):
        """c'tor

    :param self: self reference
    :param list args: args list
    :param dict kwargs: args dict
    """
        ## parent class init
        RequestTask.__init__(self, *args, **kwargs)
        ## set request type
        self.setRequestType("transfer")
        ## operation handlers
        self.addOperationAction("putAndRegister", self.putAndRegister)
        self.addOperationAction("replicateAndRegister",
                                self.replicateAndRegister)
예제 #12
0
  def testAPI( self ):
    """ test API
    """
    rt = importlib.import_module( 'DIRAC.RequestManagementSystem.private.RequestTask' )
    rt.gMonitor = MagicMock()
    rt.Operations = self.mockOps
    rt.CS = MagicMock()

    self.task = RequestTask( self.req.toJSON()["Value"], self.handlersDict, 'csPath', 'RequestManagement/RequestExecutingAgent',
                             requestClient = self.mockRC )
    self.task.requestClient = Mock( return_value = Mock( spec = ReqClient ) )
    self.task.requestClient().updateRequest = Mock()
    self.task.requestClient().updateRequest.return_value = { "OK" : True, "Value" : None }
    ret = self.task()
    self.assertEqual( ret["OK"], True , "call failed" )

    ret = self.task.setupProxy()
    print ret