|
1 | 1 | """Test for WMS clients."""
|
2 | 2 | # pylint: disable=protected-access, missing-docstring, invalid-name
|
3 | 3 |
|
| 4 | +from pathlib import Path |
| 5 | +import shutil |
4 | 6 | import pytest
|
5 | 7 |
|
6 | 8 | from unittest.mock import MagicMock
|
@@ -280,3 +282,30 @@ def test_DLI_execute_NoLocal(mocker, dli, mockSE):
|
280 | 282 | assert res["Value"]["Failed"]
|
281 | 283 | assert "/a/lfn/1.txt" in res["Value"]["Failed"], res
|
282 | 284 | assert res["Value"]["Failed"][0] == "/a/lfn/1.txt", res
|
| 285 | + |
| 286 | + |
| 287 | +def test_DLI_execute_jobIDPath(mocker, dli, mockSE): |
| 288 | + """Specify a jobIDPath. Output should be in the jobIDPath directory.""" |
| 289 | + mocker.patch("DIRAC.WorkloadManagementSystem.Client.DownloadInputData.gConfig.getValue", return_value=2) |
| 290 | + |
| 291 | + # Create the jobIDPath directory |
| 292 | + jobIDPath = Path().cwd() / "job" / "12345" |
| 293 | + jobIDPath.mkdir(parents=True, exist_ok=True) |
| 294 | + |
| 295 | + dli.configuration["JobIDPath"] = str(jobIDPath) |
| 296 | + |
| 297 | + mocker.patch("DIRAC.WorkloadManagementSystem.Client.DownloadInputData.gConfig.getValue", return_value=2) |
| 298 | + mockObjectSE = mockSE.return_value |
| 299 | + mockObjectSE.getFileMetadata.return_value = S_OK( |
| 300 | + {"Successful": {"/a/lfn/1.txt": {"Cached": 1, "Accessible": 0}}, "Failed": {}} |
| 301 | + ) |
| 302 | + dli._downloadFromSE = MagicMock(side_effect=[S_ERROR("Failed to down"), S_OK({"path": jobIDPath / "1.txt"})]) |
| 303 | + dli._isCache = MagicMock(return_value=True) |
| 304 | + res = dli.execute(dataToResolve=["/a/lfn/1.txt"]) |
| 305 | + |
| 306 | + assert res["OK"] |
| 307 | + assert not res["Value"]["Failed"] |
| 308 | + assert "/a/lfn/1.txt" in res["Value"]["Successful"], res |
| 309 | + |
| 310 | + # Check that the output path is in the jobIDPath directory |
| 311 | + assert res["Value"]["Successful"]["/a/lfn/1.txt"]["path"] == jobIDPath / "1.txt", res |
0 commit comments