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