def test_from_baton_wrapper_file_replicas(self): replicas = [ baton_models.DataObjectReplica(number=1, checksum="123abc"), baton_models.DataObjectReplica(number=2, checksum="abc"),] data_obj = baton_models.DataObject(path='/humgen/projects/helic/123.bam', replicas=replicas) raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(len(raw_meta.file_replicas), 2)
def test_from_baton_wrapper_missing_bits(self): replicas = [ baton_models.DataObjectReplica(number=1, checksum="123abc", host='hgi-dev', resource_name='irods-s1', up_to_date=True)] metadata = baton_coll.IrodsMetadata({'study': set(['BLUEPRINT'])}) data_obj = baton_models.DataObject(path='/somepath/file.txt', metadata=metadata, replicas=replicas) raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(len(raw_meta.file_replicas), 1) self.assertEqual(len(raw_meta.acls), 0)
def test_from_baton_wrapper_acls(self): user = "******" acl = [baton_models.AccessControl(user, level=baton_models.AccessControl.Level.WRITE)] data_obj = baton_models.DataObject(path='/somepath/file.txt', access_controls=acl) raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(len(raw_meta.acls), 1) self.assertEqual(raw_meta.acls[0].access_group, 'hgi') self.assertEqual(raw_meta.acls[0].permission, IrodsPermission.WRITE) self.assertEqual(raw_meta.acls[0].zone, 'Sanger1')
def test_from_baton_wrapper_all_ok(self): user = "******" acl = [baton_models.AccessControl(user, level=baton_models.AccessControl.Level.OWN)] replicas = [ baton_models.DataObjectReplica(number=1, checksum="123abc", host='hgi-dev', resource_name='irods-s1', up_to_date=True)] data_obj = baton_models.DataObject(path='/somepath/file.txt', access_controls=acl, replicas=replicas) raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(raw_meta.fpath, '/somepath/file.txt') self.assertEqual(len(raw_meta.file_replicas), 1) self.assertEqual(len(raw_meta.acls), 1) self.assertEqual(raw_meta.acls[0].zone, 'humgen') self.assertEqual(raw_meta.acls[0].access_group, 'serapis')
def test_from_baton_wrapper_full_obj(self): user = "******" acl = [baton_models.AccessControl(user, level=baton_models.AccessControl.Level.OWN)] replicas = [ baton_models.DataObjectReplica(number=1, checksum="123abc", host='hgi-dev', resource_name='irods-s1', up_to_date=True), baton_models.DataObjectReplica(number=2, checksum="abc", host='hgi-dev-wow', resource_name='irods-s2', up_to_date=True),] metadata = baton_coll.IrodsMetadata({'study': set(['BLUEPRINT'])}) data_obj = baton_models.DataObject(path='/somepath/file.txt', access_controls=acl, metadata=metadata, replicas=replicas) raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(raw_meta.fpath, '/somepath/file.txt') self.assertEqual(len(raw_meta.file_replicas), 2) self.assertEqual(len(raw_meta.acls), 1) self.assertEqual(raw_meta.acls[0].zone, 'humgen') self.assertEqual(raw_meta.acls[0].access_group, 'hgi')
def test_from_baton_wrapper_fpath_2(self): data_obj = baton_models.DataObject(path='/humgen/projects/helic/123.bam') raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(raw_meta.fpath, '/humgen/projects/helic/123.bam')
def test_from_baton_wrapper_fpath_1(self): data_obj = baton_models.DataObject(path='/seq/123/123.bam.bai') raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(raw_meta.fpath, '/seq/123/123.bam.bai')
def test_from_baton_wrapper_metadata(self): metadata = baton_coll.IrodsMetadata({'study': set(['BLUEPRINT']), 'sample': set(['123sam'])}) data_obj = baton_models.DataObject(path='/somepath/file.txt', metadata=metadata) raw_meta = IrodsRawFileMetadata.from_baton_wrapper(data_obj) self.assertEqual(raw_meta.get_values_for_attribute('study'), set(['BLUEPRINT']))