Ejemplo n.º 1
0
def create_entity_tree(id=0, text=None):  # pylint: disable=W0622
    my_entity_grandchild = MyEntityGrandchild(id=id, text=text)
    my_entity_child = MyEntityChild(id=id, text=text, children=[my_entity_grandchild])
    my_entity_parent = MyEntityParent(id=id, text=text)
    my_entity = MyEntity(id=id, text=text, children=[my_entity_child], parent=my_entity_parent)
    # If we run with the SQLAlchemy backend, the back references are populated
    # automatically.
    if my_entity_child.parent is None:
        my_entity_child.parent = my_entity
    if my_entity_grandchild.parent is None:
        my_entity_grandchild.parent = my_entity_child
    return my_entity
Ejemplo n.º 2
0
def create_entity(entity_id=0, entity_text=None):
    my_entity_parent = MyEntityParent(id=entity_id, text=entity_text)
    my_entity_grandchild = MyEntityGrandchild(id=entity_id, text=entity_text)
    my_entity_child = MyEntityChild(id=entity_id,
                                    text=entity_text,
                                    children=[my_entity_grandchild])
    my_entity = MyEntity(id=entity_id,
                         text=entity_text,
                         parent=my_entity_parent,
                         children=[my_entity_child])
    # If we run with the SQLAlchemy backend, the back references are populated
    # automatically.
    if my_entity_child.parent is None:
        my_entity_child.parent = my_entity
    if my_entity_grandchild.parent is None:
        my_entity_grandchild.parent = my_entity_child
    return my_entity
Ejemplo n.º 3
0
def create_entity(entity_id=0, entity_text=None):
    my_entity_parent = MyEntityParent(id=entity_id, text=entity_text)
    my_entity_grandchild = MyEntityGrandchild(id=entity_id, text=entity_text)
    my_entity_child = MyEntityChild(id=entity_id,
                                    text=entity_text,
                                    children=[my_entity_grandchild])
    my_entity = MyEntity(id=entity_id,
                         text=entity_text,
                         parent=my_entity_parent,
                         children=[my_entity_child])
    # If we run with the SQLAlchemy backend, the back references are populated
    # automatically.
    if my_entity_child.parent is None:
        my_entity_child.parent = my_entity
    if my_entity_grandchild.parent is None:
        my_entity_grandchild.parent = my_entity_child
    return my_entity
Ejemplo n.º 4
0
def _make_test_entity_member():
    parent = MyEntityParent(id=0)
    entity = MyEntity(id=0, parent=parent)
    parent.child = entity
    child = MyEntityChild(id=0, parent=entity)
    entity.children.append(child)
    grandchild = MyEntityGrandchild(id=0, parent=child)
    child.children.append(grandchild)
    coll = create_staging_collection(IMyEntity)
    return coll.create_member(entity)
Ejemplo n.º 5
0
def create_entity(entity_id=0, entity_text=None):
    my_entity = MyEntity(text=entity_text)
    my_entity.id = entity_id
    my_entity_parent = MyEntityParent()
    my_entity_parent.id = entity_id
    my_entity.parent = my_entity_parent
    my_entity_child = MyEntityChild()
    my_entity_child.id = entity_id
    my_entity.children.append(my_entity_child)
    my_entity_grandchild = MyEntityGrandchild()
    my_entity_grandchild.id = entity_id
    my_entity_child.children.append(my_entity_grandchild)
    # If we run with the SQLAlchemy backend, the back references are populated
    # automatically.
    if my_entity_child.parent is None:
        my_entity_child.parent = my_entity
    if my_entity_grandchild.parent is None:
        my_entity_grandchild.parent = my_entity_child
    return my_entity
Ejemplo n.º 6
0
def create_entity_tree(id=0, text=None):  # pylint: disable=W0622
    my_entity_grandchild = MyEntityGrandchild(id=id, text=text)
    my_entity_child = MyEntityChild(id=id,
                                    text=text,
                                    children=[my_entity_grandchild])
    my_entity_parent = MyEntityParent(
        id=id,
        text=text,
    )
    my_entity = MyEntity(id=id,
                         text=text,
                         children=[my_entity_child],
                         parent=my_entity_parent)
    # If we run with the SQLAlchemy backend, the back references are populated
    # automatically.
    if my_entity_child.parent is None:
        my_entity_child.parent = my_entity
    if my_entity_grandchild.parent is None:
        my_entity_grandchild.parent = my_entity_child
    return my_entity
Ejemplo n.º 7
0
def _make_test_entity_member():
    parent = MyEntityParent()
    entity = MyEntity(parent=parent)
    if parent.child is None:
        parent.child = entity
    child = MyEntityChild()
    entity.children.append(child)
    if child.parent is None:
        child.parent = entity
    grandchild = MyEntityGrandchild()
    child.children.append(grandchild)
    if grandchild.parent is None:
        grandchild.parent = child
    coll = create_staging_collection(IMyEntity)
    mb = coll.create_member(entity)
    parent.id = 0
    entity.id = 0
    child.id = 0
    grandchild.id = 0
    return mb
Ejemplo n.º 8
0
def _make_test_entity_member():
    parent = MyEntityParent()
    entity = MyEntity(parent=parent)
    if parent.child is None:
        parent.child = entity
    child = MyEntityChild()
    entity.children.append(child)
    if child.parent is None:
        child.parent = entity
    grandchild = MyEntityGrandchild()
    child.children.append(grandchild)
    if grandchild.parent is None:
        grandchild.parent = child
    coll = create_staging_collection(IMyEntity)
    mb = coll.create_member(entity)
    parent.id = 0
    entity.id = 0
    child.id = 0
    grandchild.id = 0
    return mb
Ejemplo n.º 9
0
def create_entity(entity_id=0, entity_text=None):
    my_entity = MyEntity(text=entity_text)
    my_entity.id = entity_id
    my_entity_parent = MyEntityParent()
    my_entity_parent.id = entity_id
    my_entity.parent = my_entity_parent
    my_entity_child = MyEntityChild()
    my_entity_child.id = entity_id
    my_entity_child.parent = my_entity
    if len(my_entity.children) == 0:
        # Tests that use the ORM will not need to go here.
        my_entity.children.append(my_entity_child)
        assert len(my_entity.children) == 1
    my_entity_grandchild = MyEntityGrandchild()
    my_entity_grandchild.id = entity_id
    my_entity_grandchild.parent = my_entity_child
    # Tests that use the ORM will not need this.
    if len(my_entity.children) == 0:
        my_entity.children.append(my_entity_child)
    if len(my_entity_child.children) == 0:
        my_entity_child.children.append(my_entity_grandchild)
    return my_entity
Ejemplo n.º 10
0
def create_entity(entity_id=0, entity_text=None):
    my_entity = MyEntity(text=entity_text)
    my_entity.id = entity_id
    my_entity_parent = MyEntityParent()
    my_entity_parent.id = entity_id
    my_entity.parent = my_entity_parent
    my_entity_child = MyEntityChild()
    my_entity_child.id = entity_id
    my_entity_child.parent = my_entity
    if len(my_entity.children) == 0:
        # Tests that use the ORM will not need to go here.
        my_entity.children.append(my_entity_child)
        assert len(my_entity.children) == 1
    my_entity_grandchild = MyEntityGrandchild()
    my_entity_grandchild.id = entity_id
    my_entity_grandchild.parent = my_entity_child
    # Tests that use the ORM will not need this.
    if len(my_entity.children) == 0:
        my_entity.children.append(my_entity_child)
    if len(my_entity_child.children) == 0:
        my_entity_child.children.append(my_entity_grandchild)
    return my_entity