Пример #1
0
def test_flow_id_does_not_affect_task_ids():
    f = Flow(name="test")
    f.add_task(get_task("x"))

    f2 = Flow(name="test")
    f2.add_task(get_task("x"))

    f3 = Flow(name="foo")
    f3.add_task(get_task("x"))

    assert f.generate_local_task_ids() == f2.generate_local_task_ids()
    assert f.generate_local_task_ids() == f3.generate_local_task_ids()
Пример #2
0
def test_modify_task_changes_hash():
    f = Flow(name="test")
    t = Task()
    f.add_task(t)
    hash1 = f.generate_local_task_ids()
    # this is not an attribute referenced in task.serialize(), so it should not affect the id
    t.new_attribute = "hi"
    hash2 = f.generate_local_task_ids()
    # this is an attribute referenced in task.serialize(), so it should affect the id
    t.slug = "hi"
    hash3 = f.generate_local_task_ids()
    assert hash1 == hash2
    assert hash1 != hash3
Пример #3
0
def test_ten_independent_tasks():
    """
    x1
    x2
    ...
    x10

    Ten identical but independent tasks
    """
    f = Flow(name="test")
    for i in range(1, 11):
        f.add_task(get_task("x{}".format(i)))

    steps = f.generate_local_task_ids(_debug_steps=True)

    # each task generates the same id based on its own characteristics
    assert count_unique_ids(steps[1]) == 1

    # each step generates new ids
    assert steps[1] != steps[2] != steps[3] != steps[4] != steps[5]

    # ...but the ids are not unique
    for i in range(1, 5):
        assert count_unique_ids(steps[i]) == 1

    # disambiguation finally takes place in step 5
    assert count_unique_ids(steps[5]) == 10
Пример #4
0
def test_one_task():
    """
    x1

    A single task
    """
    f = Flow(name="test")
    f.add_task(get_task("x1"))
    steps = f.generate_local_task_ids(_debug_steps=True)

    # the task is uniquely identified by its own characteristics
    assert count_unique_ids(steps[1]) == 1

    # no further processing
    assert steps[1] == steps[2] == steps[3] == steps[4] == steps[5]
Пример #5
0
def test_two_dependent_tasks():
    """
    x1 -> x2

    Two identical tasks in a row
    """
    f = Flow(name="test")
    f.add_edge(get_task("x1"), get_task("x2"))
    steps = f.generate_local_task_ids(_debug_steps=True)

    # step 1 isn't enough to differentiate the tasks
    assert count_unique_ids(steps[1]) == 1

    # step 2 is able to differentiate them
    assert count_unique_ids(steps[2]) == 2

    # no further processing
    assert steps[2] == steps[3] == steps[4] == steps[5]
Пример #6
0
def test_ten_different_tasks():
    """
    x1
    x2
    ...
    x10

    Ten non-identical and independent tasks
    """
    f = Flow(name="test")
    for i in range(1, 11):
        f.add_task(Task(name=str(i)))

    steps = f.generate_local_task_ids(_debug_steps=True)

    # tasks are immediately identifiable
    assert count_unique_ids(steps[1]) == 10

    # no further processing
    assert steps[1] == steps[2] == steps[3] == steps[4] == steps[5]