def test_resolve_no_resolver(self): context = DependencyContext([], Language({}, 'lang'), Configuration({}, [], None)) with pytest.raises(ValueError) as info: context.resolve() assert info.value.args[ 0] == 'The language, lang, does not provide a means of resolving dependencies.'
def test_resolve_to_nothing(self): dep = _make_dep(name='resolve-to-nothing') language = Language({}, 'lang') context = DependencyContext([dep], language, Configuration({}, [], None)) language.resolver = MagicMock(return_value=None) with pytest.raises(ValueError) as info: context.resolve() assert info.value.args[0] == 'Dependency path:\nresolve-to-nothing:resolve-to-nothing:1.2.3\nThe dependency, ' \ 'resolve-to-nothing:resolve-to-nothing:1.2.3, could not be resolved.' language.resolver.assert_called_once_with(context, dep)
def test_resolve_no_dependencies(self): language = Language({}, 'lang') context = DependencyContext([], language, Configuration({}, [], None)) language.resolver = MagicMock() assert context.resolve() == []
def test_resolve_version_mismatch(self): dep1 = _make_dep(version='1.2.3') dep2 = _make_dep(version='4.5.6') path = Path('/path/to/file.txt') language = Language({}, 'lang') path_set = DependencyPathSet(dep1, path) context = DependencyContext([dep1, dep2], language, Configuration({}, [], None)) language.resolver = MagicMock(return_value=path_set) with pytest.raises(ValueError) as info: context.resolve() assert info.value.args[0] == 'The same library, name:name, is required at two different versions, 1.2.3 vs. ' \ '4.5.6.' language.resolver.assert_called_once_with(context, dep1)
def test_resolve_duplicates(self): dep = _make_dep() path = Path('/path/to/file.txt') language = Language({}, 'lang') path_set = DependencyPathSet(dep, path) context = DependencyContext([dep, dep], language, Configuration({}, [], None)) language.resolver = MagicMock(return_value=path_set) assert context.resolve() == [path_set] language.resolver.assert_called_once_with(context, dep)