def test_get_all_in_collection_when_collection_contains_data_objects_and_collections(self): data_object = create_data_object(self.test_with_baton, NAMES[0], self.metadata_1) create_collection(self.test_with_baton, NAMES[1], self.metadata_2) retrieved_entities = self.create_mapper().get_all_in_collection(data_object.get_collection_path()) self.assertEqual(len(retrieved_entities), 1) self.assertIsInstance(retrieved_entities[0], type(self.create_irods_entity(NAMES[2])))
def create_collection_with_baton_json_representation() -> Tuple[Collection, Dict]: """ Creates a collection and returns it along with the JSON representation of it given by baton. Uses baton to get the JSON representation on the first use: the JSON is retrieved from a cache in subsequent uses. :return: a tuple where the first element is the created collection and the second is its JSON representation according to baton """ global _collection, _collection_as_json # Starting baton is expensive - get view of baton JSON and cache if _collection is None: test_with_baton = TestWithBaton() test_with_baton.setup() metadata = IrodsMetadata({"attribute_a": {"value_1", "value_2"}, "attribute_b": {"value_3"}}) _collection = create_collection(test_with_baton, "collection_1", metadata) baton_query = { BATON_COLLECTION_PROPERTY: _collection.path } baton_runner = BatonRunner(test_with_baton.baton_location, test_with_baton.irods_server.users[0].zone) _collection_as_json = baton_runner.run_baton_query( BatonBinary.BATON_LIST, ["--acl", "--avu"], input_data=baton_query)[0] return deepcopy(_collection), deepcopy(_collection_as_json)
def create_irods_entity(self, name: str, metadata: IrodsMetadata=IrodsMetadata()) -> Collection: return create_collection(self.test_with_baton, name, metadata)
def create_irods_entity(self, name: str, access_controls: Iterable[AccessControl]) -> Collection: return create_collection(self.test_with_baton, name, access_controls=access_controls)
def test_get_by_metadata_when_collection_with_matching_metadata(self): data_object = self.create_irods_entity(NAMES[0], self.metadata_1) create_collection(self.test_with_baton, NAMES[1], self.metadata_1_2) retrieved_entities = self.create_mapper().get_by_metadata(self.search_criterion_1) self.assertEqual(retrieved_entities, [data_object])