def test_get_hashes_local_repository_cache_miss(from_line, pypi_repository):
    existing_pins = {}
    local_repository = LocalRequirementsRepository(existing_pins,
                                                   pypi_repository)
    with pypi_repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line("cffi==1.9.1"))
        assert hashes == EXPECTED
def test_toggle_reuse_hashes_local_repository(capsys, pip_conf, from_line,
                                              pypi_repository, reuse_hashes,
                                              expected):
    # Create an install requirement with the hashes included in its options
    options = {
        "hashes": {
            "sha256": [entry.split(":")[1] for entry in NONSENSE]
        }
    }
    req = from_line("small-fake-a==0.1", options=options)
    existing_pins = {key_from_ireq(req): req}

    local_repository = LocalRequirementsRepository(existing_pins,
                                                   pypi_repository,
                                                   reuse_hashes=reuse_hashes)
    with local_repository.allow_all_wheels():
        assert local_repository.get_hashes(
            from_line("small-fake-a==0.1")) == expected
    captured = capsys.readouterr()
    assert captured.out == ""
    if reuse_hashes:
        assert captured.err == ""
    else:
        assert (captured.err.strip() ==
                "Couldn't get hashes from PyPI, fallback to hashing files")
def test_get_hashes_local_repository_cache_miss(pip_conf, from_line,
                                                pypi_repository):
    existing_pins = {}
    local_repository = LocalRequirementsRepository(existing_pins,
                                                   pypi_repository)
    with local_repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line("small-fake-a==0.1"))
        assert hashes == EXPECTED
def test_local_repository_copy_ireq_dependencies(from_line):
    # Ensure that local repository forwards any messages to update its state
    # of ireq dependencies.
    checker = FakeRepositoryChecksForCopy()
    local_repository = LocalRequirementsRepository({}, checker)

    src = from_line("small-fake-a==0.1")
    dest = copy.deepcopy(src)
    local_repository.copy_ireq_dependencies(src, dest)

    assert src in checker.copied
def test_get_hashes_local_repository_cache_miss(from_line):
    pip_command = get_pip_command()
    pip_options, _ = pip_command.parse_args([])
    session = pip_command._build_session(pip_options)
    repository = PyPIRepository(pip_options, session)

    existing_pins = {}
    local_repository = LocalRequirementsRepository(existing_pins, repository)
    with repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line('cffi==1.9.1'))
        assert hashes == EXPECTED
def test_get_hashes_local_repository_cache_miss(capsys, pip_conf, from_line,
                                                pypi_repository):
    existing_pins = {}
    local_repository = LocalRequirementsRepository(existing_pins,
                                                   pypi_repository)
    with local_repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line("small-fake-a==0.1"))
        assert hashes == EXPECTED
    captured = capsys.readouterr()
    assert captured.out == ""
    assert captured.err == ""
def test_get_hashes_local_repository_cache_hit(from_line, repository):
    # Create an install requirement with the hashes included in its options
    options = {"hashes": {"sha256": [entry.split(":")[1] for entry in EXPECTED]}}
    req = from_line("small-fake-a==0.1", options=options)
    existing_pins = {name_from_req(req): req}

    # Use fake repository so that we know the hashes are coming from cache
    local_repository = LocalRequirementsRepository(existing_pins, repository)
    with local_repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line("small-fake-a==0.1"))
        assert hashes == EXPECTED
def test_get_hashes_local_repository_cache_hit(from_line, repository):
    # Create an install requirement with the hashes included in its options
    options = {}
    options['hashes'] = {'sha256': [entry.split(':')[1] for entry in EXPECTED]}
    req = from_line('cffi==1.9.1', options=options)
    existing_pins = {name_from_req(req): req}

    # Use fake repository so that we know the hashes are coming from cache
    local_repository = LocalRequirementsRepository(existing_pins, repository)
    with repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line('cffi==1.9.1'))
        assert hashes == EXPECTED
示例#9
0
def test_get_hashes_local_repository_cache_hit(from_line, repository):
    # Create an install requirement with the hashes included in its options
    options = {}
    options['hashes'] = {'sha256': [entry.split(':')[1] for entry in EXPECTED]}
    req = from_line('cffi==1.9.1', options=options)
    existing_pins = {name_from_req(req): req}

    # Use fake repository so that we know the hashes are coming from cache
    local_repository = LocalRequirementsRepository(existing_pins, repository)
    with repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line('cffi==1.9.1'))
        assert hashes == EXPECTED
示例#10
0
def test_get_hashes_local_repository_cache_miss(from_line):
    pip_command = get_pip_command()
    pip_options, _ = pip_command.parse_args(
        ['--index-url', PyPIRepository.DEFAULT_INDEX_URL])
    session = pip_command._build_session(pip_options)
    repository = PyPIRepository(pip_options, session)

    existing_pins = {}
    local_repository = LocalRequirementsRepository(existing_pins, repository)
    with repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line('cffi==1.9.1'))
        assert hashes == EXPECTED
示例#11
0
def test_get_hashes_local_repository_cache_miss(capfd, pip_conf, from_line,
                                                pypi_repository):
    existing_pins = {}
    local_repository = LocalRequirementsRepository(existing_pins,
                                                   pypi_repository)
    with local_repository.allow_all_wheels():
        hashes = local_repository.get_hashes(from_line("small-fake-a==0.1"))
        assert hashes == EXPECTED
    captured = capfd.readouterr()
    assert captured.out == ""
    assert (captured.err.strip() ==
            "Couldn't get hashes from PyPI, fallback to hashing files")
def test_toggle_reuse_hashes_local_repository(
    pip_conf, from_line, pypi_repository, reuse_hashes, expected
):
    # Create an install requirement with the hashes included in its options
    options = {"hashes": {"sha256": [entry.split(":")[1] for entry in NONSENSE]}}
    req = from_line("small-fake-a==0.1", options=options)
    existing_pins = {name_from_req(req): req}

    local_repository = LocalRequirementsRepository(
        existing_pins, pypi_repository, reuse_hashes=reuse_hashes
    )
    with local_repository.allow_all_wheels():
        assert local_repository.get_hashes(from_line("small-fake-a==0.1")) == expected