class TestDataObject(unittest.TestCase):
    """
    Tests for `DataObject`.
    """
    def setUp(self):
        self.entity = DataObject("%s/%s" % (_COLLECTION, _FILE_NAME))

    def test_get_collection_path(self):
        self.assertEquals(self.entity.get_collection_path(), _COLLECTION)

    def test_get_name(self):
        self.assertEquals(self.entity.get_name(), _FILE_NAME)

    def test_equality(self):
        data_object_2 = copy.deepcopy(self.entity)
        self.assertEqual(data_object_2, self.entity)
Esempio n. 2
0
def create_entity_tree(
    test_with_baton: TestWithBaton, root: str, node: EntityNode, access_controls: Iterable[AccessControl] = None
) -> Iterable[IrodsEntity]:
    """
    TODO
    :param test_with_baton:
    :param root:
    :param node:
    :param access_controls:
    :return:
    """
    entities = []
    setup_helper = SetupHelper(test_with_baton.icommands_location)

    if isinstance(node, DataObjectNode):
        entity = DataObject(setup_helper.create_data_object(node.name))
    else:
        entity = Collection(setup_helper.create_collection(node.name))

    _set_access_controls(test_with_baton, entity.path, access_controls)
    entity.access_controls = access_controls

    new_path = "%s/%s" % (root, entity.get_name())
    setup_helper.run_icommand(["imv", entity.path, new_path])
    entity.path = new_path
    entities.append(entity)

    if isinstance(node, CollectionNode):
        for child in node.children:
            descendants = create_entity_tree(test_with_baton, "%s/%s" % (root, node.name), child, access_controls)
            entities.extend(descendants)

    if isinstance(node, CollectionNode):
        assert len(entities) == len(list(node.get_all_descendants()) + [node])
    else:
        assert len(entities) == 1
    return entities
 def setUp(self):
     self.entity = DataObject("%s/%s" % (_COLLECTION, _FILE_NAME))
 def test_convert_if_no_metadata(self):
     converted = convert_data_object(DataObject(self.path))
     self.assertEqual(converted.fpath, self.path)
 def setUp(self):
     self.path = "/path"
     self.data_object = DataObject(self.path,
                                   metadata=IrodsMetadata(),
                                   replicas={})
 def setUp(self):
     self.data_objects = [
         DataObject("/path_1"),
         DataObject("/path_2"),
         DataObject("/path_3")
     ]