Example #1
0
def test_add_dependency_group_to_resource():
    foo = Library('foo', '')
    a1 = Resource(foo, 'a1.js')
    b1 = Resource(foo, 'b1.js', depends=[a1])
    c1 = Resource(foo, 'c1.js', depends=[b1])

    assert a1.depends == set([])
    assert a1.resources == set([a1])

    assert b1.depends == set([a1])
    assert b1.resources == set([a1, b1])

    assert c1.depends == set([b1])
    assert c1.resources == set([a1, b1, c1])

    a2 = Resource(foo, 'a2.js')
    a3 = Group([a1, a2])
    b1.add_dependency(a3)

    assert b1.depends == set([a1, a3])
    assert b1.resources == set([a1, a2, b1])

    assert c1.depends == set([b1])
    assert c1.resources == set([a1, a2, b1, c1])

    # Adding it twice does not change anything.
    b1.add_dependency(a3)

    assert b1.depends == set([a1, a3])
    assert b1.resources == set([a1, a2, b1])

    assert c1.depends == set([b1])
    assert c1.resources == set([a1, a2, b1, c1])
Example #2
0
def test_cannot_add_dependency_loop():
    foo = Library('foo', '')
    a1 = Resource(foo, 'a1.js')
    b1 = Resource(foo, 'b1.js', depends=[a1])

    with pytest.raises(ValueError):
        a1.add_dependency(b1)