Esempio n. 1
0
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)
    hashes = local_repository.get_hashes(from_line('cffi==1.9.1'))
    assert all(x in EXPECTED for x in hashes)
    assert hashes
Esempio n. 2
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)
    hashes = local_repository.get_hashes(from_line('cffi==1.9.1'))
    assert all(x in EXPECTED for x in hashes)
    assert hashes