Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dvc/output/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _parse_path(self, remote, path):
# so we should expect both posix and windows style paths.
# PathInfo accepts both, i.e. / works everywhere, \ only on win.
#
# FIXME: if we have Windows path containig / or posix one with \
# FIXME: if we have Windows path containing / or posix one with \
# then we have #2059 bug and can't really handle that.
p = self.REMOTE.path_cls(path)
if not p.is_absolute():
Expand Down
3 changes: 2 additions & 1 deletion dvc/repo/get_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def get_url(url, out=None):

if os.path.exists(url):
url = os.path.abspath(url)
out = os.path.abspath(out)

out = os.path.abspath(out)

dep, = dependency.loads_from(None, [url])
out, = output.loads_from(None, [out], use_cache=False)
Expand Down
30 changes: 30 additions & 0 deletions tests/func/test_get_url.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
from __future__ import unicode_literals

import os
import boto3
import filecmp

import pytest

from moto import mock_s3

from dvc.remote import RemoteS3
from dvc.repo import Repo
from dvc.utils import makedirs

from tests.func.test_data_cloud import get_aws_url


def test_get_file(repo_dir):
src = repo_dir.FOO
Expand All @@ -32,3 +38,27 @@ def test_get_url_to_dir(dname, repo_dir):

assert os.path.isdir(dname)
assert filecmp.cmp(repo_dir.DATA, dst, shallow=False)


@mock_s3
@pytest.mark.parametrize("dst", [".", "./from"])
def test_get_url_from_non_local_path_to_dir_and_file(repo_dir, dst):
file_name = "from"
file_content = "data"
base_info = RemoteS3.path_cls(get_aws_url())
from_info = base_info / file_name

s3 = boto3.client("s3")
s3.create_bucket(Bucket=from_info.bucket)
s3.put_object(
Bucket=from_info.bucket, Key=from_info.path, Body=file_content
)

Repo.get_url(from_info.url, dst)

result_path = os.path.join(dst, file_name) if os.path.isdir(dst) else dst

assert os.path.exists(result_path)
assert os.path.isfile(result_path)
with open(result_path, "r") as fd:
assert fd.read() == file_content