Skip to content

Commit ef1fd54

Browse files
chore: improve UploadLogFile tests
1 parent 3dc8df3 commit ef1fd54

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

test/test_commands.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ def basedir(self):
2929

3030
yield tmpdir
3131

32+
def test_correct_file_finding(self, basedir):
33+
"""Test output file finding."""
34+
from dirac_cwl_proto.commands.upload_log_file import obtain_output_files
35+
36+
files = obtain_output_files(basedir)
37+
files_names = [os.path.basename(file_path) for file_path in files]
38+
39+
assert set(self.FILENAMES).difference(files_names) == {"file.extra"}
40+
3241
def test_upload_ok(self, basedir, mocker: MockerFixture):
3342
"""Test a correct upload."""
3443
base_lfn = f"/lhcb/{self.NAMESPACE}/{self.CONFIG_VERSION}/LOG/{self.PRODUCTION_ID.zfill(8)}/0000/"
@@ -85,11 +94,12 @@ def test_upload_ok_to_failover(self, basedir, mocker: MockerFixture):
8594
assert result["OK"]
8695

8796
def test_upload_fail(self, basedir, mocker: MockerFixture):
88-
"""Test both a failure to LogSE and the FailoverSE."""
97+
"""Test both a failure to upload to the LogSE and the FailoverSE."""
8998
base_lfn = f"/lhcb/{self.NAMESPACE}/{self.CONFIG_VERSION}/LOG/{self.PRODUCTION_ID.zfill(8)}/0000/"
9099
zip_name = self.JOB_ID.zfill(8) + ".zip"
91100

92101
expected_lfn = os.path.join(base_lfn, zip_name)
102+
expected_zip = os.path.join(basedir, zip_name)
93103

94104
mock_put = mocker.patch("dirac_cwl_proto.data_management_mocks.data_manager.MockDataManager.put")
95105
mock_putAndRegister = mocker.patch(
@@ -107,6 +117,8 @@ def test_upload_fail(self, basedir, mocker: MockerFixture):
107117
config_version=self.CONFIG_VERSION,
108118
)
109119

120+
mock_put.assert_called_once_with(expected_lfn, expected_zip, "LogSE")
121+
mock_putAndRegister.assert_called_once_with(expected_lfn, expected_zip, "Tier1-Failover")
110122
assert not result["OK"]
111123

112124
# TO TEST: Failed to zip files - No outputs generated by the job

0 commit comments

Comments
 (0)