示例#1
0
def test_two_generation_properties(task_v1_session):
    parent_task = Task(desc="parent", first_scope="2021-ww24.5")
    task_v1_session.add(parent_task)
    task_v1_session.flush()

    child_task = Task(desc="child", first_scope="2021-ww24.6")
    child_task.parent_id = parent_task.task_id
    task_v1_session.add(child_task)
    task_v1_session.commit()

    assert not parent_task.parent
    assert parent_task.children == [child_task]

    assert child_task.parent == parent_task
    assert not child_task.children
示例#2
0
def test_2g_sqlalchemy_relationships(task_v1_session):
    parent_task = Task(desc="parent", first_scope="2021-ww24.5")
    task_v1_session.add(parent_task)
    task_v1_session.flush()

    child_task = Task(desc="child", first_scope="2021-ww24.6")
    child_task.parent_id = parent_task.task_id
    task_v1_session.add(child_task)
    task_v1_session.commit()

    bystander = Task(desc="completely unrelated task",
                     first_scope="2021-ww02.1")
    task_v1_session.add(bystander)

    bystander2 = Task(desc="totally unrelated task", first_scope="2021-ww03.1")
    task_v1_session.add(bystander2)
    task_v1_session.commit()

    assert not parent_task.parent
    assert parent_task.children == [child_task]

    assert child_task.parent == parent_task
    assert not child_task.children