def test_split_entity_namespaces(): """Test split_entity_namespaces""" e = { 'concreteType': 'org.sagebionetworks.repo.model.Folder', 'name': 'Henry', 'color': 'blue', 'foo': 1234, 'parentId': 'syn1234' } (properties, annotations, local_state) = split_entity_namespaces(e) assert set(properties.keys()) == {'concreteType', 'name', 'parentId'} assert properties['name'] == 'Henry' assert set(annotations.keys()) == {'color', 'foo'} assert annotations['foo'] == 1234 assert len(local_state) == 0 e = { 'concreteType': 'org.sagebionetworks.repo.model.FileEntity', 'name': 'Henry', 'color': 'blue', 'foo': 1234, 'parentId': 'syn1234', 'dataFileHandleId': 54321, 'cacheDir': '/foo/bar/bat', 'files': ['foo.xyz'], 'path': '/foo/bar/bat/foo.xyz' } (properties, annotations, local_state) = split_entity_namespaces(e) assert set(properties.keys()) == { 'concreteType', 'name', 'parentId', 'dataFileHandleId' } assert properties['name'] == 'Henry' assert properties['dataFileHandleId'] == 54321 assert set(annotations.keys()) == {'color', 'foo'} assert annotations['foo'] == 1234 assert set(local_state.keys()) == {'cacheDir', 'files', 'path'} assert local_state['cacheDir'] == '/foo/bar/bat' f = Entity.create(properties, annotations, local_state) assert f.properties.dataFileHandleId == 54321 assert f.properties.name == 'Henry' assert f.annotations.foo == 1234 assert f.__dict__['cacheDir'] == '/foo/bar/bat' assert f.__dict__['path'] == '/foo/bar/bat/foo.xyz'
def test_split_entity_namespaces(): """Test split_entity_namespaces""" e = { 'concreteType': 'org.sagebionetworks.repo.model.Folder', 'name': 'Henry', 'color': 'blue', 'foo': 1234, 'parentId': 'syn1234' } (properties, annotations, local_state) = split_entity_namespaces(e) assert_equals(set(properties.keys()), {'concreteType', 'name', 'parentId'}) assert_equals(properties['name'], 'Henry') assert_equals(set(annotations.keys()), {'color', 'foo'}) assert_equals(annotations['foo'], 1234) assert_equals(len(local_state), 0) e = { 'concreteType': 'org.sagebionetworks.repo.model.FileEntity', 'name': 'Henry', 'color': 'blue', 'foo': 1234, 'parentId': 'syn1234', 'dataFileHandleId': 54321, 'cacheDir': '/foo/bar/bat', 'files': ['foo.xyz'], 'path': '/foo/bar/bat/foo.xyz' } (properties, annotations, local_state) = split_entity_namespaces(e) assert_equals(set(properties.keys()), {'concreteType', 'name', 'parentId', 'dataFileHandleId'}) assert_equals(properties['name'], 'Henry') assert_equals(properties['dataFileHandleId'], 54321) assert_equals(set(annotations.keys()), {'color', 'foo'}) assert_equals(annotations['foo'], 1234) assert_equals(set(local_state.keys()), {'cacheDir', 'files', 'path'}) assert_equals(local_state['cacheDir'], '/foo/bar/bat') f = Entity.create(properties, annotations, local_state) assert_equals(f.properties.dataFileHandleId, 54321) assert_equals(f.properties.name, 'Henry') assert_equals(f.annotations.foo, 1234) assert_equals(f.__dict__['cacheDir'], '/foo/bar/bat') assert_equals(f.__dict__['path'], '/foo/bar/bat/foo.xyz')
def test_EntityViewSchema__ignore_column_names_set_info_preserved(): """ tests that ignoredAnnotationColumnNames will be preserved after creating a new EntityViewSchema from properties, local_state, and annotations """ ignored_names = {'a', 'b', 'c'} entity_view = EntityViewSchema("someName", parent="syn123", ignoredAnnotationColumnNames={'a', 'b', 'c'}) properties, annotations, local_state = split_entity_namespaces(entity_view) entity_view_copy = Entity.create(properties, annotations, local_state) assert_equals(ignored_names, entity_view.ignoredAnnotationColumnNames) assert_equals(ignored_names, entity_view_copy.ignoredAnnotationColumnNames)
def test_EntityViewSchema__ignore_column_names_set_info_preserved(): """ tests that ignoredAnnotationColumnNames will be preserved after creating a new EntityViewSchema from properties, local_state, and annotations """ ignored_names = {'a', 'b', 'c'} entity_view = EntityViewSchema("someName", parent="syn123", ignoredAnnotationColumnNames={'a', 'b', 'c'}) properties, annotations, local_state = split_entity_namespaces(entity_view) entity_view_copy = Entity.create(properties, annotations, local_state) assert ignored_names == entity_view.ignoredAnnotationColumnNames assert ignored_names == entity_view_copy.ignoredAnnotationColumnNames
def test_split_entity_namespaces(): """Test split_entity_namespaces""" e = {'concreteType':'org.sagebionetworks.repo.model.Folder', 'name':'Henry', 'color':'blue', 'foo':1234, 'parentId':'syn1234'} (properties,annotations,local_state) = split_entity_namespaces(e) assert set(properties.keys()) == set(['concreteType', 'name', 'parentId']) assert properties['name'] == 'Henry' assert set(annotations.keys()) == set(['color', 'foo']) assert annotations['foo'] == 1234 assert len(local_state) == 0 e = {'concreteType':'org.sagebionetworks.repo.model.FileEntity', 'name':'Henry', 'color':'blue', 'foo':1234, 'parentId':'syn1234', 'dataFileHandleId':54321, 'cacheDir':'/foo/bar/bat', 'files':['foo.xyz'], 'path':'/foo/bar/bat/foo.xyz'} (properties,annotations,local_state) = split_entity_namespaces(e) assert set(properties.keys()) == set(['concreteType', 'name', 'parentId', 'dataFileHandleId']) assert properties['name'] == 'Henry' assert properties['dataFileHandleId'] == 54321 assert set(annotations.keys()) == set(['color', 'foo']) assert annotations['foo'] == 1234 assert set(local_state.keys()) == set(['cacheDir', 'files', 'path']) assert local_state['cacheDir'] == '/foo/bar/bat' f = Entity.create(properties,annotations,local_state) assert f.properties.dataFileHandleId == 54321 assert f.properties.name == 'Henry' assert f.annotations.foo == 1234 assert f.__dict__['cacheDir'] == '/foo/bar/bat' assert f.__dict__['path'] == '/foo/bar/bat/foo.xyz'
def test_split_entity_namespaces(): """Test split_entity_namespaces""" e = {'concreteType': 'org.sagebionetworks.repo.model.Folder', 'name': 'Henry', 'color': 'blue', 'foo': 1234, 'parentId': 'syn1234'} (properties, annotations, local_state) = split_entity_namespaces(e) assert_equals(set(properties.keys()), {'concreteType', 'name', 'parentId'}) assert_equals(properties['name'], 'Henry') assert_equals(set(annotations.keys()), {'color', 'foo'}) assert_equals(annotations['foo'], 1234) assert_equals(len(local_state), 0) e = {'concreteType': 'org.sagebionetworks.repo.model.FileEntity', 'name': 'Henry', 'color': 'blue', 'foo': 1234, 'parentId': 'syn1234', 'dataFileHandleId': 54321, 'cacheDir': '/foo/bar/bat', 'files': ['foo.xyz'], 'path': '/foo/bar/bat/foo.xyz'} (properties, annotations, local_state) = split_entity_namespaces(e) assert_equals(set(properties.keys()), {'concreteType', 'name', 'parentId', 'dataFileHandleId'}) assert_equals(properties['name'], 'Henry') assert_equals(properties['dataFileHandleId'], 54321) assert_equals(set(annotations.keys()), {'color', 'foo'}) assert_equals(annotations['foo'], 1234) assert_equals(set(local_state.keys()), {'cacheDir', 'files', 'path'}) assert_equals(local_state['cacheDir'], '/foo/bar/bat') f = Entity.create(properties, annotations, local_state) assert_equals(f.properties.dataFileHandleId, 54321) assert_equals(f.properties.name, 'Henry') assert_equals(f.annotations.foo, 1234) assert_equals(f.__dict__['cacheDir'], '/foo/bar/bat') assert_equals(f.__dict__['path'], '/foo/bar/bat/foo.xyz')