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
11 changes: 5 additions & 6 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,19 @@
from tests.utils import spy

from tests.remotes import (
_should_test_aws,
_should_test_gcp,
_should_test_hdfs,
_should_test_ssh,
Azure,
GDrive,
S3,
OSS,
TEST_CONFIG,
TEST_SECTION,
TEST_GCP_CREDS_FILE,
TEST_GDRIVE_CLIENT_ID,
TEST_GDRIVE_CLIENT_SECRET,
TEST_REMOTE,
get_aws_url,
get_gcp_url,
get_hdfs_url,
get_local_url,
Expand Down Expand Up @@ -195,10 +194,10 @@ def test(self):

class TestRemoteS3(TestDataCloudBase):
def _should_test(self):
return _should_test_aws()
return S3.should_test()

def _get_url(self):
return get_aws_url()
return S3.get_url()

def _get_cloud_class(self):
return RemoteS3
Expand Down Expand Up @@ -469,10 +468,10 @@ def _test(self):

class TestRemoteS3CLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_aws()
return S3.should_test()

def _test(self):
url = get_aws_url()
url = S3.get_url()

self.main(["remote", "add", TEST_REMOTE, url])

Expand Down
4 changes: 2 additions & 2 deletions tests/func/test_repro.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
from dvc.utils.stage import load_stage_file
from tests.basic_env import TestDvc
from tests.remotes import (
_should_test_aws,
_should_test_gcp,
_should_test_hdfs,
_should_test_ssh,
get_ssh_url,
S3,
TEST_AWS_REPO_BUCKET,
TEST_GCP_REPO_BUCKET,
)
Expand Down Expand Up @@ -954,7 +954,7 @@ def test(self, mock_prompt):
@pytest.mark.skipif(os.name == "nt", reason="temporarily disabled on windows")
class TestReproExternalS3(TestReproExternalBase):
def should_test(self):
return _should_test_aws()
return S3.should_test()

@property
def scheme(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/func/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from moto import mock_s3

from dvc.remote.s3 import RemoteS3
from tests.remotes import get_aws_url
from tests.remotes import S3


# from https://github.com/spulec/moto/blob/v1.3.5/tests/test_s3/test_s3.py#L40
Expand All @@ -30,7 +30,7 @@ def wrapped(*args, **kwargs):


def _get_src_dst():
base_info = RemoteS3.path_cls(get_aws_url())
base_info = RemoteS3.path_cls(S3.get_url())
return base_info / "from", base_info / "to"


Expand Down
44 changes: 21 additions & 23 deletions tests/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@
TEST_GDRIVE_CLIENT_SECRET = "2fy_HyzSwkxkGzEken7hThXb"


def _should_test_aws():
do_test = env2bool("DVC_TEST_AWS", undefined=None)
if do_test is not None:
return do_test

if os.getenv("AWS_ACCESS_KEY_ID") and os.getenv("AWS_SECRET_ACCESS_KEY"):
return True

return False


def _should_test_gcp():
do_test = env2bool("DVC_TEST_GCP", undefined=None)
if do_test is not None:
Expand Down Expand Up @@ -156,14 +145,6 @@ def get_hdfs_url():
)


def get_aws_storagepath():
return TEST_AWS_REPO_BUCKET + "/" + str(uuid.uuid4())


def get_aws_url():
return "s3://" + get_aws_storagepath()


def get_gcp_storagepath():
return TEST_GCP_REPO_BUCKET + "/" + str(uuid.uuid4())

Expand All @@ -179,13 +160,30 @@ class Local:


class S3:
should_test = staticmethod(_should_test_aws)
get_url = staticmethod(get_aws_url)
@staticmethod
def should_test():
do_test = env2bool("DVC_TEST_AWS", undefined=None)
if do_test is not None:
return do_test

if os.getenv("AWS_ACCESS_KEY_ID") and os.getenv(
"AWS_SECRET_ACCESS_KEY"
):
return True

return False

@staticmethod
def get_storagepath():
return TEST_AWS_REPO_BUCKET + "/" + str(uuid.uuid4())

@staticmethod
def get_url():
return "s3://" + S3.get_storagepath()


class S3Mocked:
class S3Mocked(S3):
should_test = staticmethod(lambda: True)
get_url = staticmethod(get_aws_url)

@classmethod
@contextmanager
Expand Down