Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / sdk / python / tests / test_sdk.py
1 import mock
2 import os
3 import unittest
4
5 import arvados
6 import arvados.collection
7
8 class TestSDK(unittest.TestCase):
9
10     @mock.patch('arvados.api')
11     @mock.patch('arvados.current_task')
12     @mock.patch('arvados.current_job')
13     def test_one_task_per_input_file_normalize(self, mock_job, mock_task, mock_api):
14         # This manifest will be reduced from three lines to one when it is
15         # normalized.
16         nonnormalized_manifest = """. 5348b82a029fd9e971a811ce1f71360b+43 0:43:md5sum.txt
17 . 085c37f02916da1cad16f93c54d899b7+41 0:41:md5sum.txt
18 . 8b22da26f9f433dea0a10e5ec66d73ba+43 0:43:md5sum.txt
19 """
20         dummy_hash = 'ffffffffffffffffffffffffffffffff+0'
21
22         mock_job.return_value = {
23             'uuid': 'none',
24             'script_parameters': {
25                 'input': dummy_hash
26             }
27         }
28         mock_task.return_value = {
29             'uuid': 'none',
30             'sequence': 0,
31         }
32         # mock the API client to return a collection with a nonnormalized manifest.
33         mock_api('v1').collections().get().execute.return_value = {
34             'uuid': 'zzzzz-4zz18-mockcollection0',
35             'portable_data_hash': dummy_hash,
36             'manifest_text': nonnormalized_manifest,
37         }
38
39         # Because one_task_per_input_file normalizes this collection,
40         # it should now create only one job task and not three.
41         arvados.job_setup.one_task_per_input_file(and_end_task=False)
42         mock_api('v1').job_tasks().create().execute.assert_called_once_with()
43