예제 #1
0
def test_toggle_reuse_hashes_local_repository(capfd, 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
    captured = capfd.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")
예제 #2
0
def test_no_upgrades(base_resolver, repository, from_line, input, pins, expected):
    input = [from_line(line) for line in input]
    existing_pins = dict()
    for line in pins:
        ireq = from_line(line)
        existing_pins[name_from_req(ireq.req)] = ireq
    local_repository = LocalRequirementsRepository(existing_pins, repository)
    output = base_resolver(input, prereleases=False, repository=local_repository).resolve()
    output = {str(line) for line in output}
    assert output == {str(line) for line in expected}
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
예제 #4
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
예제 #5
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
예제 #6
0
def test_no_upgrades(base_resolver, repository, from_line, input, pins,
                     expected):
    input = [from_line(line) for line in input]
    existing_pins = dict()
    for line in pins:
        ireq = from_line(line)
        existing_pins[name_from_req(ireq.req)] = ireq
    local_repository = LocalRequirementsRepository(existing_pins, repository)
    output = base_resolver(input,
                           prereleases=False,
                           repository=local_repository).resolve()
    output = {str(line) for line in output}
    assert output == {str(line) for line in expected}
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
예제 #8
0
def test_name_from_req_with_project_name(from_line):
    ireq = from_line("foo==1.8")
    ireq.req.project_name = "bar"
    assert name_from_req(ireq.req) == "bar"
예제 #9
0
def test_name_from_req(from_line):
    ireq = from_line("django==1.8")
    assert name_from_req(ireq.req) == "django"
예제 #10
0
def test_name_from_req_with_project_name(from_line):
    ireq = from_line("foo==1.8")
    ireq.req.project_name = "bar"
    assert name_from_req(ireq.req) == "bar"
예제 #11
0
def test_name_from_req(from_line):
    ireq = from_line("django==1.8")
    assert name_from_req(ireq.req) == "django"
예제 #12
0
def test_name_from_req_with_project_name(from_line):
    ireq = from_line('foo==1.8')
    ireq.req.project_name = 'bar'
    assert name_from_req(ireq.req) == 'bar'
예제 #13
0
def test_name_from_req(from_line):
    ireq = from_line('django==1.8')
    assert name_from_req(ireq.req) == 'django'