Esempio n. 1
0
def test_extra():
    repo = WarehouseAPIRepo(name='pypi', url=DEFAULT_WAREHOUSE)

    coroutine = repo.get_dependencies(name='requests', version='2.21.0')
    deps = loop.run_until_complete(asyncio.gather(coroutine))[0]
    deps = {dep.name: dep for dep in deps}
    assert 'chardet' in deps
    assert 'cryptography' not in deps
    assert 'win-inet-pton' not in deps

    coroutine = repo.get_dependencies(name='requests', version='2.21.0', extra='security')
    deps = loop.run_until_complete(asyncio.gather(coroutine))[0]
    deps = {dep.name: dep for dep in deps}
    assert 'chardet' not in deps
    assert 'win-inet-pton' not in deps
    assert 'cryptography' in deps
Esempio n. 2
0
def test_get_deps(asyncio_mock, temp_cache, fixtures_path: Path):
    url = 'https://custom.pypi.org/pypi/'
    text = (fixtures_path / 'warehouse-api-release.json').read_text()
    asyncio_mock.get(url + 'dephell-shells/0.1.2/json', body=text)

    repo = WarehouseAPIRepo(name='pypi', url=url)
    coroutine = repo.get_dependencies(name='dephell-shells', version='0.1.2')
    deps = loop.run_until_complete(asyncio.gather(coroutine))[0]
    deps = {dep.name: dep for dep in deps}
    assert set(deps) == {'attrs', 'pexpect', 'shellingham'}
Esempio n. 3
0
def cache(deps):
    repo = WarehouseAPIRepo(name='pypi', url=DEFAULT_WAREHOUSE)
    tasks = []
    for dep in islice(deps, 1000):
        for release in repo.get_releases(dep):
            task = asyncio.ensure_future(repo.get_dependencies(
                release.name,
                release.version,
            ))
            tasks.append(task)
    loop.run_until_complete(asyncio.gather(*tasks))
Esempio n. 4
0
def test_get_deps_auth(asyncio_mock, temp_cache, fixtures_path: Path):
    url = 'https://custom.pypi.org/pypi/'
    text = (fixtures_path / 'warehouse-api-release.json').read_text()
    asyncio_mock.get(url + 'dephell-shells/0.1.2/json', body=text)

    auth = Auth(
        hostname='custom.pypi.org',
        username='******',
        password='******',
    )
    repo = WarehouseAPIRepo(name='pypi', url=url, auth=auth)
    coroutine = repo.get_dependencies(name='dephell-shells', version='0.1.2')
    deps = loop.run_until_complete(asyncio.gather(coroutine))[0]
    deps = {dep.name: dep for dep in deps}

    assert set(deps) == {'attrs', 'pexpect', 'shellingham'}
    assert len(asyncio_mock.requests) == 1
    client = list(asyncio_mock.requests.values())[0][0].args[0]
    assert client._default_headers['authorization'] == 'Basic Z3JhbTp0ZXN0'
Esempio n. 5
0
def test_info_from_files():
    repo = WarehouseAPIRepo(name='pypi', url=DEFAULT_WAREHOUSE)
    coroutine = repo.get_dependencies(name='m2r', version='0.2.1')
    deps = loop.run_until_complete(asyncio.gather(coroutine))[0]
    deps = {dep.name: dep for dep in deps}
    assert set(deps) == {'mistune', 'docutils'}