1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
10 import arvados.collection
12 class TestSDK(unittest.TestCase):
14 @mock.patch('arvados.current_task')
15 @mock.patch('arvados.current_job')
16 def test_one_task_per_input_file_normalize(self, mock_job, mock_task):
17 mock_api = mock.MagicMock()
19 # This manifest will be reduced from three lines to one when it is
21 nonnormalized_manifest = """. 5348b82a029fd9e971a811ce1f71360b+43 0:43:md5sum.txt
22 . 085c37f02916da1cad16f93c54d899b7+41 0:41:md5sum.txt
23 . 8b22da26f9f433dea0a10e5ec66d73ba+43 0:43:md5sum.txt
25 dummy_hash = 'ffffffffffffffffffffffffffffffff+0'
27 mock_job.return_value = {
29 'script_parameters': {
33 mock_task.return_value = {
37 # mock the API client to return a collection with a nonnormalized manifest.
38 mock_api.collections().get().execute.return_value = {
39 'uuid': 'zzzzz-4zz18-mockcollection0',
40 'portable_data_hash': dummy_hash,
41 'manifest_text': nonnormalized_manifest,
44 # Because one_task_per_input_file normalizes this collection,
45 # it should now create only one job task and not three.
46 arvados.job_setup.one_task_per_input_file(and_end_task=False, api_client=mock_api)
47 mock_api.job_tasks().create().execute.assert_called_once_with()