コード例 #1
0
ファイル: test_git_resolving.py プロジェクト: yyolk/dephell
def test_with_rev_two_constraints():
    commit = '0cf85e6b074794ac91857aa097f0b3dc3e6d9468'
    dep = DependencyMaker.from_params(
        raw_name='Django',
        constraint='',
        source=RootDependency(),
        url='https://github.com/django/django.git@' + commit,
    )[0]
    assert isinstance(dep.link, VCSLink)
    assert isinstance(dep.repo, GitRepo)
    dep.repo = PatchedGitRepo(dep.link)

    dep2 = DependencyMaker.from_params(
        raw_name='Django',
        constraint='<=1.11',
        source=RootDependency(),
    )[0]
    dep += dep2
    dep3 = DependencyMaker.from_params(
        raw_name='Django',
        constraint='>=1.7',
        source=RootDependency(),
    )[0]
    dep += dep3
    assert isinstance(dep.link, VCSLink)

    releases = set()
    for group in dep.groups:
        releases.update(set(group.releases))
    assert len(releases) == 1

    versions = {str(release.version) for release in releases}
    assert versions == {'1.11'}
コード例 #2
0
ファイル: test_git_resolving.py プロジェクト: yyolk/dephell
def test_no_rev_two_constraints():
    dep = DependencyMaker.from_params(
        raw_name='Django',
        constraint='',
        source=RootDependency(),
        url='https://github.com/django/django.git',
    )[0]
    assert isinstance(dep.link, VCSLink)
    assert isinstance(dep.repo, GitRepo)
    dep.repo = PatchedGitRepo(dep.link)

    dep2 = DependencyMaker.from_params(
        raw_name='Django',
        constraint='<=1.9',
        source=RootDependency(),
    )[0]
    dep += dep2
    assert isinstance(dep.link, VCSLink)

    releases = set()
    for group in dep.groups:
        releases.update(set(group.releases))
    assert len(releases) == 2

    versions = {str(release.version) for release in releases}
    assert versions == {'1.7', '1.9'}
コード例 #3
0
def test_format_req():
    deps = DependencyMaker.from_params(
        raw_name='Django',
        constraint='>=1.9',
        source=RootDependency(),
    )
    content = PIPFileConverter()._format_req(Requirement(deps[0], lock=False))
    assert content == '>=1.9'
コード例 #4
0
ファイル: test_git_resolving.py プロジェクト: yyolk/dephell
def test_with_rev_two_constraints_unresolved():
    commit = '0cf85e6b074794ac91857aa097f0b3dc3e6d9468'
    dep = DependencyMaker.from_params(
        raw_name='Django',
        constraint='',
        source=RootDependency(),
        url='https://github.com/django/django.git@' + commit,
    )[0]
    assert isinstance(dep.link, VCSLink)
    assert isinstance(dep.repo, GitRepo)
    dep.repo = PatchedGitRepo(dep.link)

    dep2 = DependencyMaker.from_params(
        raw_name='Django',
        constraint='<=1.9',
        source=RootDependency(),
    )[0]
    dep += dep2
    for group in dep.groups:
        assert group.empty
    assert not dep.compat
コード例 #5
0
def test_repository_preserve(converter):
    repo = RepositoriesRegistry()
    repo.add_repo(url='https://example.com', name='insane')
    repo.add_repo(url='https://pypi.org/simple/', name='pypi')
    root = RootDependency()
    dep1 = DependencyMaker.from_params(
        source=root,
        raw_name='dephell',
        constraint='*',
        repo=repo,
    )[0]
    req = Requirement(dep=dep1, roots=[root.name], lock=False)

    content1 = converter.dumps([req], project=root)
    root2 = converter.loads(content1)
    assert len(root2.dependencies) == 1
    dep2 = root2.dependencies[0]

    repos1 = [attr.asdict(repo) for repo in dep1.repo.repos]
    repos2 = [attr.asdict(repo) for repo in dep2.repo.repos]
    assert repos1 == repos2
コード例 #6
0
ファイル: test_git_resolving.py プロジェクト: yyolk/dephell
def test_with_rev_one_constraint():
    commit = '0cf85e6b074794ac91857aa097f0b3dc3e6d9468'
    dep = DependencyMaker.from_params(
        raw_name='Django',
        constraint='',
        source=RootDependency(),
        url='https://github.com/django/django.git@' + commit,
    )[0]
    assert isinstance(dep.link, VCSLink)
    assert isinstance(dep.repo, GitRepo)
    dep.repo = PatchedGitRepo(dep.link)

    releases = set()
    non_empty = 0
    for group in dep.groups:
        non_empty += not group.empty
        releases.update(set(group.releases))
    assert non_empty == 1
    assert len(releases) == 1

    release = list(releases)[0]
    assert isinstance(release, GitRelease)
    assert release.commit == commit
    assert str(release.version) == '1.11'