1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
11 class TaskOutputDirTest(unittest.TestCase):
13 self.tmp = tempfile.mkdtemp()
14 os.environ['TASK_KEEPMOUNT_TMP'] = self.tmp
17 os.environ.pop('TASK_KEEPMOUNT_TMP')
18 shutil.rmtree(self.tmp)
20 def test_env_var(self):
21 out = arvados.crunch.TaskOutputDir()
22 self.assertEqual(out.path, self.tmp)
24 with open(os.path.join(self.tmp, '.arvados#collection'), 'w') as f:
25 f.write('{\n "manifest_text":"",\n "uuid":null\n}\n')
26 self.assertEqual(out.manifest_text(), '')
28 # Special file must be re-read on each call to manifest_text().
29 with open(os.path.join(self.tmp, '.arvados#collection'), 'w') as f:
30 f.write(r'{"manifest_text":". unparsed 0:3:foo\n","uuid":null}')
31 self.assertEqual(out.manifest_text(), ". unparsed 0:3:foo\n")