@@ -2955,6 +2955,60 @@ def test_replica_truncate__issue_534(self):
29552955 if data_objs .exists (data_path ):
29562956 data_objs .unlink (data_path , force = True )
29572957
2958+ def test_get_collection_returns_a_reference_exclusively_to_an_existing_collection__issue_734 (
2959+ self ,
2960+ ):
2961+ from irods .helpers import get_collection , get_data_object
2962+
2963+ sess = self .sess
2964+ logical_path = "{}/{}" .format (
2965+ self .coll_path , unique_name (my_function_name (), datetime .now ())
2966+ )
2967+ sess .collections .create (logical_path )
2968+
2969+ self .assertIs (get_data_object (sess , logical_path ), None )
2970+ self .assertTrue (get_collection (sess , logical_path ))
2971+
2972+ def test_get_data_object_returns_a_reference_exclusively_to_an_existing_data_object__issue_734 (
2973+ self ,
2974+ ):
2975+ from irods .helpers import get_collection , get_data_object
2976+
2977+ sess = self .sess
2978+ logical_path = "{}/{}" .format (
2979+ self .coll_path , unique_name (my_function_name (), datetime .now ())
2980+ )
2981+ sess .data_objects .create (logical_path )
2982+
2983+ self .assertIs (get_collection (sess , logical_path ), None )
2984+ self .assertTrue (get_data_object (sess , logical_path ))
2985+
2986+ def test_data_object_download_error_leaves_no_file_relic__issue_681 (self ):
2987+ from irods .helpers import get_collection , get_data_object
2988+
2989+ sess = self .sess
2990+
2991+ # Generate a test path.
2992+ data_path = "{}/{}" .format (
2993+ self .coll_path , unique_name (my_function_name (), datetime .now ())
2994+ )
2995+
2996+ # Test that neither a data object nor a collection exists at the data_path.
2997+ self .assertIs (None , get_data_object (sess , data_path ))
2998+ self .assertIs (None , get_collection (sess , data_path ))
2999+
3000+ # Make sure that no directory or file exists at the download target path in the local filesystem.
3001+ with NamedTemporaryFile (delete = True ) as f :
3002+ local_path = f .name
3003+ self .assertFalse (os .path .exists (local_path ))
3004+
3005+ # Attempt downloading the nonexisting object, expecting an error.
3006+ with self .assertRaises ((ex .DataObjectDoesNotExist , ex .OBJ_PATH_DOES_NOT_EXIST )):
3007+ sess .data_objects .get (data_path , local_path )
3008+
3009+ # Assert no relic left at local_path.
3010+ self .assertFalse (os .path .exists (local_path ))
3011+
29583012
29593013if __name__ == "__main__" :
29603014 # let the tests find the parent irods lib
0 commit comments