Ejemplo n.º 1
0
def test_download_fails_on_error_code(dvc_repo):
    with StaticFileServer() as httpd:
        url = "http://localhost:{}/".format(httpd.server_port)
        config = {"url": url}

        remote = RemoteHTTP(dvc_repo, config)

        with pytest.raises(HTTPError):
            remote._download(URLInfo(url) / "missing.txt", "missing.txt")
Ejemplo n.º 2
0
def test_public_auth_method(dvc):
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "user": "",
        "password": "",
    }

    remote = RemoteHTTP(dvc, config)

    assert remote.auth_method() is None
Ejemplo n.º 3
0
def test_custom_auth_method(dvc):
    header = "Custom-Header"
    password = "******"
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "auth": "custom",
        "custom_auth_header": header,
        "password": password,
    }

    remote = RemoteHTTP(dvc, config)

    assert remote.auth_method() is None
    assert header in remote.headers
    assert remote.headers[header] == password
Ejemplo n.º 4
0
def test_no_traverse_compatibility(dvc_repo):
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "no_traverse": False,
    }

    with pytest.raises(ConfigError):
        RemoteHTTP(dvc_repo, config)
Ejemplo n.º 5
0
def test_digest_auth_method(dvc):
    from requests.auth import HTTPDigestAuth

    user = "******"
    password = "******"
    auth = HTTPDigestAuth(user, password)
    config = {
        "url": "http://example.com/",
        "path_info": "file.html",
        "auth": "digest",
        "user": user,
        "password": password,
    }

    remote = RemoteHTTP(dvc, config)

    assert remote.auth_method() == auth
    assert isinstance(remote.auth_method(), HTTPDigestAuth)
Ejemplo n.º 6
0
Archivo: http.py Proyecto: ml-lab/dvc
    def __init__(self, stage, path, info=None, remote=None):
        super(DependencyHTTP, self).__init__(stage, path, info=info)

        self.remote = remote or RemoteHTTP(stage.project, {})

        if path.startswith('remote'):
            path = urljoin(self.remote.cache_dir, urlparse(path).path)

        self.path_info = {
            'scheme': urlparse(path).scheme,
            'path': path,
        }