From 554300e76561021bd26f9143cdece13dd80341cd Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Fri, 26 Jun 2015 15:52:46 -0400 Subject: [PATCH] Fix bad CollectionReader reference in arv-put. No issue #. --- sdk/python/arvados/commands/put.py | 5 +++-- sdk/python/tests/test_arv_put.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py index d8ed90bda0..496db86ab4 100644 --- a/sdk/python/arvados/commands/put.py +++ b/sdk/python/arvados/commands/put.py @@ -5,6 +5,7 @@ import argparse import arvados +import arvados.collection import base64 import datetime import errno @@ -479,14 +480,14 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr): if args.stream: output = writer.manifest_text() if args.normalize: - output = CollectionReader(output).manifest_text(normalize=True) + output = arvados.collection.CollectionReader(output).manifest_text(normalize=True) elif args.raw: output = ','.join(writer.data_locators()) else: try: manifest_text = writer.manifest_text() if args.normalize: - manifest_text = CollectionReader(manifest_text).manifest_text(normalize=True) + manifest_text = arvados.collection.CollectionReader(manifest_text).manifest_text(normalize=True) replication_attr = 'replication_desired' if api_client._schema.schemas['Collection']['properties'].get(replication_attr, None) is None: # API called it 'redundancy' before #3410. diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py index d078268c83..d337023a61 100644 --- a/sdk/python/tests/test_arv_put.py +++ b/sdk/python/tests/test_arv_put.py @@ -381,6 +381,20 @@ class ArvadosPutTest(run_test_server.TestCaseWithServers, ArvadosBaseTestCase): arv_put.ResumeCache.CACHE_DIR = orig_cachedir os.chmod(cachedir, 0o700) + def test_normalize(self): + testfile1 = self.make_test_file() + testfile2 = self.make_test_file() + test_paths = [testfile1.name, testfile2.name] + # Reverse-sort the paths, so normalization must change their order. + test_paths.sort(reverse=True) + self.call_main_with_args(['--stream', '--no-progress', '--normalize'] + + test_paths) + manifest = self.main_stdout.getvalue() + # Assert the second file we specified appears first in the manifest. + file_indices = [manifest.find(':' + os.path.basename(path)) + for path in test_paths] + self.assertGreater(*file_indices) + def test_error_name_without_collection(self): self.assertRaises(SystemExit, self.call_main_with_args, ['--name', 'test without Collection', -- 2.30.2