Exemplo n.º 1
0
def test_inverse_map_sub2():
    m = InverseMap()

    animal = MapKey('animal')
    elephant = MapKey('elephant', parents=[animal])
    african_elephant = MapKey('african elephant', parents=[elephant])

    m.register(african_elephant, 'African Elephant')

    assert list(m.all(animal)) == ['African Elephant']
    assert list(m.all(elephant)) == ['African Elephant']
    assert list(m.all(african_elephant)) == ['African Elephant']
Exemplo n.º 2
0
def test_inverse_map_sub2():
    m = InverseMap()

    animal = MapKey('animal')
    elephant = MapKey('elephant', parents=[animal])
    african_elephant = MapKey('african elephant', parents=[elephant])

    m.register(african_elephant, 'African Elephant')

    assert list(m.all(animal)) == ['African Elephant']
    assert list(m.all(elephant)) == ['African Elephant']
    assert list(m.all(african_elephant)) == ['African Elephant']
Exemplo n.º 3
0
def test_inverse_map_registration_order():
    m = InverseMap()

    animal = MapKey('animal')
    elephant = MapKey('elephant', parents=[animal])
    african_elephant = MapKey('african elephant', parents=[elephant])

    m.register(elephant, 'Elephant')
    m.register(animal, 'Animal')

    assert list(m.all(animal)) == ['Animal', 'Elephant']
    assert list(m.all(elephant)) == ['Elephant']
    assert list(m.all(african_elephant)) == []
Exemplo n.º 4
0
def test_inverse_map_registration_order():
    m = InverseMap()

    animal = MapKey('animal')
    elephant = MapKey('elephant', parents=[animal])
    african_elephant = MapKey('african elephant', parents=[elephant])

    m.register(elephant, 'Elephant')
    m.register(animal, 'Animal')

    assert list(m.all(animal)) == ['Animal', 'Elephant']
    assert list(m.all(elephant)) == ['Elephant']
    assert list(m.all(african_elephant)) == []
Exemplo n.º 5
0
def test_inverse_map_two_descendants():
    m = InverseMap()

    animal = MapKey('animal')
    elephant = MapKey('elephant', parents=[animal])
    rhino = MapKey('rhino', parents=[animal])

    m.register(elephant, 'Elephant')
    m.register(rhino, 'Rhino')

    assert list(m.all(elephant)) == ['Elephant']
    assert list(m.all(rhino)) == ['Rhino']

    # we get out the descendants in declaration order
    assert list(m.all(animal)) == ['Elephant', 'Rhino']
Exemplo n.º 6
0
def test_inverse_map_two_descendants():
    m = InverseMap()

    animal = MapKey('animal')
    elephant = MapKey('elephant', parents=[animal])
    rhino = MapKey('rhino', parents=[animal])

    m.register(elephant, 'Elephant')
    m.register(rhino, 'Rhino')

    assert list(m.all(elephant)) == ['Elephant']
    assert list(m.all(rhino)) == ['Rhino']

    # we get out the descendants in declaration order
    assert list(m.all(animal)) == ['Elephant', 'Rhino']
Exemplo n.º 7
0
def test_inverse_map_empty():
    m = InverseMap()

    animal = MapKey('animal')

    assert list(m.all(animal)) == []
Exemplo n.º 8
0
def test_inverse_map_empty():
    m = InverseMap()

    animal = MapKey('animal')

    assert list(m.all(animal)) == []