Esempio n. 1
0
def test_find_closure():
    dep_dic = {
        'A': [['B']], 'B': [['E'], ['A', 'D']], 'C': [['E', 'F']],
        'D': [['A']], 'E': [['A']], 'F': [['G']], 'G': []}
    dependencies = Dependencies(dep_dic)
    rels = dependencies.tuple_relations()
    clos = {'A', 'B', 'D', 'E'}
    assert find_closure(rels, ['A']) == clos
Esempio n. 2
0
def test_from_rels():
    dep_dic = {
        'A': [['B']], 'B': [['E'], ['A', 'D']], 'C': [['E', 'F']],
        'D': [['A']], 'E': [['A']], 'F': [['G']], 'G': []}
    dependencies = Dependencies(dep_dic)
    rels = dependencies.tuple_relations()
    dependencies_new = Dependencies.from_rels(rels)
    assert dependencies.serialize() == dependencies_new.serialize()
Esempio n. 3
0
def test_tuple_relations():
    dep_dic = {'A': [], 'B': [['A']], 'C': [['D', 'G'], ['A']],
               'D': [['A'], ['C', 'G']], 'E': [['D', 'G'], ['A'], ['C']]}
    dependencies = Dependencies(dep_dic)
    tuple_comp = [(['D', 'G'], 'C'), (['A'], 'C'), (['A'], 'B'),
                  (['D', 'G'], 'E'), (['A'], 'E'), (['C'], 'E'),
                  (['A'], 'D'), (['C', 'G'], 'D')]
    assert_equal_tuple_rels(dependencies.tuple_relations(), tuple_comp)