コード例 #1
0
ファイル: test_base_tasks.py プロジェクト: zoulianmp/HQCMeas
def test_ex_access_handling3():
    # Test moving a task with whose one entry has an ex_access.
    root = RootTask()
    task1 = ComplexTask(task_name='task1')
    root.children_task.append(task1)
    task2 = SimpleTask(task_name='task2', task_database_entries={'val2': 'r'})
    task1.children_task.append(task2)

    task1.add_access_exception('task2_val2')
    assert_equal(root.get_from_database('task2_val2'), 'r')
    task1.children_task = []
    assert_raises(KeyError, root.get_from_database, 'task2_val2')
    task1.children_task.append(task2)
    assert_equal(root.get_from_database('task2_val2'), 'r')
コード例 #2
0
def test_ex_access_handling3():
    # Test moving a task with whose one entry has an ex_access.
    root = RootTask()
    task1 = ComplexTask(task_name='task1')
    root.children_task.append(task1)
    task2 = SimpleTask(task_name='task2',
                       task_database_entries={'val2': 'r'})
    task1.children_task.append(task2)

    task1.add_access_exception('task2_val2')
    assert_equal(root.get_from_database('task2_val2'), 'r')
    task1.children_task = []
    assert_raises(KeyError, root.get_from_database, 'task2_val2')
    task1.children_task.append(task2)
    assert_equal(root.get_from_database('task2_val2'), 'r')
コード例 #3
0
ファイル: test_base_tasks.py プロジェクト: zoulianmp/HQCMeas
def test_giving_root1():
    # Test assembling a hierarchy and giving it a root task only later.
    root = RootTask()

    task1 = ComplexTask(task_name='task1')
    task2 = ComplexTask(task_name='task2')
    task1.children_task.append(task2)
    task3 = ComplexTask(task_name='task3')
    task2.children_task.append(task3)
    task4 = SimpleTask(task_name='task4', task_database_entries={'val2': 'r'})
    task3.children_task.append(task4)

    task3.access_exs = ['task4_val2']
    task2.access_exs = ['task4_val2']

    root.children_task.append(task1)

    assert_equal(task2.get_from_database('task4_val2'), 'r')
    task3.children_task = []
コード例 #4
0
ファイル: test_base_tasks.py プロジェクト: zoulianmp/HQCMeas
def test_ex_access_handling6():
    # Test moving a task to which two access exs are linked.
    root = RootTask()
    task1 = ComplexTask(task_name='task1')
    root.children_task.append(task1)
    task2 = ComplexTask(task_name='task2')
    task1.children_task.append(task2)
    task3 = ComplexTask(task_name='task3')
    task2.children_task.append(task3)
    task4 = SimpleTask(task_name='task4', task_database_entries={'val2': 'r'})
    task3.children_task.append(task4)

    task3.add_access_exception('task4_val2')
    task2.add_access_exception('task4_val2')
    assert_equal(task2.get_from_database('task4_val2'), 'r')
    task3.children_task = []
    assert_raises(KeyError, task2.get_from_database, 'task4_val2')
    task3.children_task.append(task4)
    assert_equal(task2.get_from_database('task4_val2'), 'r')
コード例 #5
0
def test_giving_root1():
    # Test assembling a hierarchy and giving it a root task only later.
    root = RootTask()

    task1 = ComplexTask(task_name='task1')
    task2 = ComplexTask(task_name='task2')
    task1.children_task.append(task2)
    task3 = ComplexTask(task_name='task3')
    task2.children_task.append(task3)
    task4 = SimpleTask(task_name='task4',
                       task_database_entries={'val2': 'r'})
    task3.children_task.append(task4)

    task3.access_exs = ['task4_val2']
    task2.access_exs = ['task4_val2']

    root.children_task.append(task1)

    assert_equal(task2.get_from_database('task4_val2'), 'r')
    task3.children_task = []
コード例 #6
0
def test_ex_access_handling6():
    # Test moving a task to which two access exs are linked.
    root = RootTask()
    task1 = ComplexTask(task_name='task1')
    root.children_task.append(task1)
    task2 = ComplexTask(task_name='task2')
    task1.children_task.append(task2)
    task3 = ComplexTask(task_name='task3')
    task2.children_task.append(task3)
    task4 = SimpleTask(task_name='task4',
                       task_database_entries={'val2': 'r'})
    task3.children_task.append(task4)

    task3.add_access_exception('task4_val2')
    task2.add_access_exception('task4_val2')
    assert_equal(task2.get_from_database('task4_val2'), 'r')
    task3.children_task = []
    assert_raises(KeyError, task2.get_from_database, 'task4_val2')
    task3.children_task.append(task4)
    assert_equal(task2.get_from_database('task4_val2'), 'r')