def test_registry_resolver_built_invalid(tmpdir):
    """Make sure we throw an error if we are asked to install an invalid built component
    """

    reg = ComponentRegistry()
    chain = DependencyResolverChain()

    tile = copy_comp('comp2_dev_v1.1', tmpdir.strpath)

    try:
        reg.add_component(comp_path('comp1_v1.1_built_empty'))
        with pytest.raises(ExternalError) as excinfo:
            for dep in tile.dependencies:
                result = chain.update_dependency(tile, dep)

        assert excinfo.value.msg == 'Component found in registry but its build/output folder is not valid'
    finally:
        reg.remove_component('comp1')
def chain_composite(request):
    """Create a multirule chain that has the registry followed by the mock resolver
    """

    reg = ComponentRegistry()
    reg.add_component(comp_path('comp3_v1.0'))

    chain = DependencyResolverChain()
    chain.rules.append([10, (re.compile('.*'), MockDependencyResolver, [comp_path('comp1_v1.1')])])
    yield chain

    reg.remove_component('comp3')
def test_registry_resolver(tmpdir):
    """Test to make sure that the registry resolver can install and update a dependency
    """

    reg = ComponentRegistry()
    chain = DependencyResolverChain()

    tile = copy_comp('comp2_dev_v1.1', tmpdir.strpath)

    try:
        reg.add_component(comp_path('comp1_v1.1'))
        for dep in tile.dependencies:
            result = chain.update_dependency(tile, dep)
            assert result == 'installed'

        for dep in tile.dependencies:
            result = chain.update_dependency(tile, dep)
            assert result == 'already installed'

        reg.remove_component('comp1')
        reg.add_component(comp_path('comp1_v1.2'))

        for dep in tile.dependencies:
            result = chain.update_dependency(tile, dep)
            assert result == 'updated'

        reg.remove_component('comp1')
        reg.add_component(comp_path('comp1_v2.0'))

        for dep in tile.dependencies:
            result = chain.update_dependency(tile, dep)
            assert result == 'already installed'
    finally:
        reg.remove_component('comp1')
def chain_comp1_v20(request):
    chain = DependencyResolverChain()
    chain.rules = [(0, (re.compile('.*'), MockDependencyResolver, [comp_path('comp1_v2.0')]))]
    return chain
Esempio n. 5
0
def test_resolverchain_defaults():
    """Make sure the ResolverChain is able to fetch default resolvers
    """

    chain = DependencyResolverChain()
    assert len(chain.rules) == 1