Beispiel #1
0
class RFCPRALImplTest(unittest.TestCase):
    def setUp(self):
        self.RFCPRALImpl = RFCPRALImpl()

    def testCreateSourceName(self):
        self.assertEqual("name", self.RFCPRALImpl.createSourceName("", "name"))
        self.assertEqual("file:////name", self.RFCPRALImpl.createSourceName("", "file:////name"))


    @mock.patch('WMCore.Storage.Backends.RFCPRALImpl.RFCPRALImpl.run')
    def testCreateOutputDirectory_error0(self, mock_runCommand):
        mock_runCommand.return_value = 0
        self.RFCPRALImpl.createOutputDirectory("dir/file/test")
        mock_runCommand.assert_called_once_with("rfstat dir/file > /dev/null ")

    @mock.patch('WMCore.Storage.Backends.RFCPRALImpl.RFCPRALImpl.run')
    def testCreateOutputDirectory_error0Exception(self, mock_runCommand):
        mock_runCommand.side_effect = Exception("Im in test, yay!")
        self.RFCPRALImpl.createOutputDirectory("dir/file/test")
        mock_runCommand.assert_called_once_with("rfstat dir/file > /dev/null ")

    def testCreateOutputDirectory_error1Exception(self):
        self.RFCPRALImpl.run = Mock()
        self.RFCPRALImpl.run.side_effect = [1, Exception()]
        self.RFCPRALImpl.createOutputDirectory("dir/file/test")
        self.RFCPRALImpl.run.assert_has_calls([call("rfstat dir/file > /dev/null "),
                                             call("rfmkdir -m 775 -p dir/file")])

    @mock.patch('WMCore.Storage.Backends.RFCPRALImpl.RFCPRALImpl.run')
    def testCreateOutputDirectory_error1(self, mock_runCommand):
        mock_runCommand.return_value = 1
        self.RFCPRALImpl.createOutputDirectory("dir/file/test")
        mock_runCommand.assert_has_calls([call("rfstat dir/file > /dev/null "),
                                          call("rfmkdir -m 775 -p dir/file")])

    def testCreateStageOutCommand_stageInTrue(self):
        self.RFCPRALImpl.stageIn = True
        sourcePFN = "file://*****:*****@mock.patch('WMCore.Storage.StageOutImpl.StageOutImpl.executeCommand')
    def testRemoveFile(self, mock_executeCommand):
        self.RFCPRALImpl.removeFile("fileName")
        mock_executeCommand.assert_called_with("stager_rm -M fileName ; nsrm fileName")

    @mock.patch('WMCore.Storage.StageOutImpl.StageOutImpl.executeCommand')
    def testRemoveFile_regex(self, mock_executeCommand):
        self.RFCPRALImpl.removeFile("//castor/ads.rl.ac.uk/prod/cms/store/unmerged//testas")
        expected="/castor/ads.rl.ac.uk/prod/cms/store/unmerged/testas"
        mock_executeCommand.assert_called_with("stager_rm -S cmsTemp -M %s ; nsrm %s" %(expected, expected))
Beispiel #2
0
 def setUp(self):
     self.RFCPRALImpl = RFCPRALImpl()