Esempio n. 1
0
def test_conda_get_releases_git():
    repo = CondaGitRepo(channels=['conda-forge'])
    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root, req='textdistance')[0]
    releases = repo.get_releases(dep=dep)
    versions = {str(release.version) for release in releases}
    assert not {'3.0.3', '3.1.0', '4.0.0', '4.1.0'} - versions
Esempio n. 2
0
def test_conda_deps_git():
    repo = CondaGitRepo(channels=['bioconda'])
    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root, req='anvio')[0]
    releases = repo.get_releases(dep=dep)
    deps = {dep.name for dep in releases[0].dependencies}
    assert 'prodigal' in deps
def test_get_releases():
    repo = WarehouseLocalRepo(name='pypi', path=Path('tests', 'repository'))
    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root, req='dephell-discover')[0]
    releases = repo.get_releases(dep=dep)
    releases = {str(r.version): r for r in releases}
    assert set(releases) == {'0.2.4', '0.2.5'}
Esempio n. 4
0
def get_deps():
    root = RootDependency()
    response = requests.get(URL)
    for info in response.json()['rows']:
        yield from DependencyMaker.from_requirement(
            source=root,
            req=Requirement(info['project']),
        )
Esempio n. 5
0
def test_get_releases():
    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root, req='dephell')[0]
    repo = WarehouseSimpleRepo(name='pypi', url=DEFAULT_WAREHOUSE)
    releases = repo.get_releases(dep=dep)
    releases = {str(r.version): r for r in releases}
    assert '0.7.0' in set(releases)
    assert str(releases['0.7.0'].python) == '>=3.5'
    assert len(releases['0.7.0'].hashes) == 2
Esempio n. 6
0
def test_get_releases_mocked(requests_mock, temp_cache, fixtures_path):
    url = 'https://artifactory.example.org/pypi/'
    text = (fixtures_path / 'warehouse-simple.html').read_text()
    requests_mock.get(url + 'dephell-shells/', text=text)

    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root, req='dephell-shells')[0]
    repo = WarehouseSimpleRepo(name='pypi', url=url)
    releases = repo.get_releases(dep=dep)

    assert requests_mock.call_count == 1
    assert len(releases) == 4
Esempio n. 7
0
def test_get_releases(requests_mock, temp_cache, fixtures_path: Path):
    url = 'https://pypi.org/pypi/'
    text = (fixtures_path / 'warehouse-api-package.json').read_text()
    requests_mock.get(url + 'dephell-shells/json', text=text)

    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root,
                                           req='dephell-shells')[0]
    repo = WarehouseAPIRepo(name='pypi', url=url)
    releases = repo.get_releases(dep=dep)

    assert requests_mock.call_count == 1
    assert len(releases) == 4
Esempio n. 8
0
def test_extract_modules(temp_path: Path, requirements_path: Path):
    config = Config()
    config.attach(dict(project=str(temp_path)))
    command = VendorDownloadCommand(argv=[], config=config)
    dep = DependencyMaker.from_requirement(source=RootDependency(),
                                           req='dephell')[0]
    result = command._extract_modules(
        dep=dep,
        archive_path=requirements_path / 'wheel.whl',
        output_path=temp_path,
    )
    assert result is True
    assert (temp_path / 'dephell').exists()
    assert (temp_path / 'dephell' / '__init__.py').exists()
Esempio n. 9
0
def test_get_releases_auth(requests_mock, temp_cache, fixtures_path):
    url = 'https://artifactory.example.org/pypi/'
    text = (fixtures_path / 'warehouse-simple.html').read_text()
    requests_mock.get(url + 'dephell-shells/', text=text)

    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root, req='dephell-shells')[0]
    auth = Auth(
        hostname='artifactory.example.org',
        username='******',
        password='******',
    )
    repo = WarehouseSimpleRepo(name='pypi', url=url, auth=auth)
    releases = repo.get_releases(dep=dep)

    assert requests_mock.call_count == 1
    assert len(releases) == 4
    assert requests_mock.last_request.headers['Authorization'] == 'Basic Z3JhbTp0ZXN0'
Esempio n. 10
0
def make_root(root, **releases) -> RootDependency:
    release_objects = []
    for name, fakes in releases.items():
        for fake in fakes:
            release = Release(
                raw_name=name,
                version=str(fake.version),
                time=DEFAULT_TIME,
            )
            release_objects.append(release)
            for extra in fake.extras:
                release = Release(
                    raw_name=name,
                    extra=extra,
                    version=str(fake.version),
                    time=DEFAULT_TIME,
                )

    constraints = defaultdict(dict)
    for name, fakes in releases.items():
        for fake in fakes:
            constraints[name][fake.version] = tuple(
                PackagingRequirement(dep) for dep in fake.deps)
            for extra, deps in fake.extras.items():
                cname = '{}[{}]'.format(name, extra)
                constraints[cname][fake.version] = tuple(
                    PackagingRequirement(dep) for dep in deps)

    repo = ReleaseRepo(*release_objects, deps=constraints)

    deps = []
    root_dep = RootDependency(raw_name=''.join(sorted(releases)))
    root_dep.repo = repo
    for constr in root.deps:
        subdeps = DependencyMaker.from_requirement(
            req=PackagingRequirement(constr),
            source=root_dep,
        )
        for dep in subdeps:
            dep.repo = repo
        deps.extend(subdeps)
    root_dep.attach_dependencies(deps)
    return root_dep
Esempio n. 11
0
def test_get_releases_auth(requests_mock, temp_cache, fixtures_path: Path):
    url = 'https://custom.pypi.org/pypi/'
    text = (fixtures_path / 'warehouse-api-package.json').read_text()
    requests_mock.get(url + 'dephell-shells/json', text=text)

    root = RootDependency()
    dep = DependencyMaker.from_requirement(source=root,
                                           req='dephell-shells')[0]
    repo = WarehouseAPIRepo(name='pypi',
                            url=url,
                            auth=Auth(
                                hostname='custom.pypi.org',
                                username='******',
                                password='******',
                            ))
    releases = repo.get_releases(dep=dep)

    assert requests_mock.call_count == 1
    assert len(releases) == 4
    assert requests_mock.last_request.headers[
        'Authorization'] == 'Basic Z3JhbTp0ZXN0'
Esempio n. 12
0
def test_format():
    root = RootDependency()
    text = ('hypothesis[django]<=3.0.0; '
            'python_version == "2.7" and '
            'platform_python_implementation == "CPython"')
    req = PackagingRequirement(text)
    deps = DependencyMaker.from_requirement(root, req)

    # test dep
    assert deps[0].name == 'hypothesis'
    assert deps[1].name == 'hypothesis[django]'
    assert str(deps[0].constraint) == '<=3.0.0'
    assert str(deps[0].marker).startswith('python_version == "2.7"')

    # test format
    req = Requirement(dep=deps[0], lock=False)
    req.extra_deps = (deps[1], )
    result = PIPConverter(lock=False)._format_req(req=req)
    assert 'hypothesis[django]' in result
    assert '<=3.0.0' in result
    assert 'python_version == "2.7"' in result
    assert 'from root' not in result
    assert result.startswith(text)
Esempio n. 13
0
def test_from_requirement():
    root = RootDependency()
    req = Requirement('Django>=1.5,<=1.9')
    dep = DependencyMaker.from_requirement(source=root, req=req)[0]
    assert dep.raw_name == 'Django'
    assert set(str(dep.constraint).split(',')) == {'>=1.5', '<=1.9'}