Esempio n. 1
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. 2
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. 3
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'