[ARVADOS] created: 1.1.0-11-g250f157

Git user git at public.curoverse.com
Tue Oct 10 11:23:11 EDT 2017


        at  250f1578314d1f4d053d3d9f65a3d5c33d1578af (commit)


commit 250f1578314d1f4d053d3d9f65a3d5c33d1578af
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Oct 10 11:19:47 2017 -0400

    12418: Explicitly check if collection is not None
    
    The empty collection evaluates to False, so it is necessary to explicitly check
    for "not None".
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/sdk/cwl/arvados_cwl/fsaccess.py b/sdk/cwl/arvados_cwl/fsaccess.py
index 08e203b..5bdd8dd 100644
--- a/sdk/cwl/arvados_cwl/fsaccess.py
+++ b/sdk/cwl/arvados_cwl/fsaccess.py
@@ -81,14 +81,14 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):
 
     def glob(self, pattern):
         collection, rest = self.get_collection(pattern)
-        if collection and not rest:
+        if collection is not None and not rest:
             return [pattern]
         patternsegments = rest.split("/")
         return self._match(collection, patternsegments, "keep:" + collection.manifest_locator())
 
     def open(self, fn, mode):
         collection, rest = self.get_collection(fn)
-        if collection:
+        if collection is not None:
             return collection.open(rest, mode)
         else:
             return super(CollectionFsAccess, self).open(self._abs(fn), mode)
@@ -105,7 +105,7 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):
 
     def isfile(self, fn):  # type: (unicode) -> bool
         collection, rest = self.get_collection(fn)
-        if collection:
+        if collection is not None:
             if rest:
                 return isinstance(collection.find(rest), arvados.arvfile.ArvadosFile)
             else:
@@ -115,7 +115,7 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):
 
     def isdir(self, fn):  # type: (unicode) -> bool
         collection, rest = self.get_collection(fn)
-        if collection:
+        if collection is not None:
             if rest:
                 return isinstance(collection.find(rest), arvados.collection.RichCollectionBase)
             else:
@@ -125,7 +125,7 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):
 
     def listdir(self, fn):  # type: (unicode) -> List[unicode]
         collection, rest = self.get_collection(fn)
-        if collection:
+        if collection is not None:
             if rest:
                 dir = collection.find(rest)
             else:
@@ -147,7 +147,7 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):
         if path.startswith("$(task.tmpdir)") or path.startswith("$(task.outdir)"):
             return path
         collection, rest = self.get_collection(path)
-        if collection:
+        if collection is not None:
             return path
         else:
             return os.path.realpath(path)
diff --git a/sdk/python/tests/test_collections.py b/sdk/python/tests/test_collections.py
index e8c6dd1..5f40bb2 100644
--- a/sdk/python/tests/test_collections.py
+++ b/sdk/python/tests/test_collections.py
@@ -97,6 +97,8 @@ class ArvadosCollectionsTest(run_test_server.TestCaseWithServers,
         self.assertEqual(stream0.readfrom(2**26, 0),
                          b'',
                          'reading zero bytes should have returned empty string')
+        self.assertEqual(3, len(cr))
+        self.assertTrue(cr)
 
     def _test_subset(self, collection, expected):
         cr = arvados.CollectionReader(collection, self.api_client)
@@ -632,6 +634,8 @@ class CollectionReaderTestCase(unittest.TestCase, CollectionTestMixin):
         reader = arvados.CollectionReader('d41d8cd98f00b204e9800998ecf8427e+0',
                                           api_client=client)
         self.assertEqual('', reader.manifest_text())
+        self.assertEqual(0, len(reader))
+        self.assertFalse(reader)
 
     def test_api_response(self):
         client = self.api_client_mock()

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list