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'
def test_get_deps_auth(requests_mock, temp_cache, fixtures_path): url = 'https://custom.pypi.org/' text = (fixtures_path / 'warehouse-simple.html').read_text() requests_mock.get(url + 'dephell-shells/', text=text) auth = Auth( hostname='custom.pypi.org', username='******', password='******', ) repo = WarehouseSimpleRepo(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 requests_mock.call_count == 1 assert requests_mock.last_request.headers['Authorization'] == 'Basic Z3JhbTp0ZXN0'
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'
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'