Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: merge _should_test_oss and _get_oss_url inside OSS test helper #3071

Merged
merged 1 commit into from
Jan 6, 2020
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 @@ -34,10 +34,10 @@
_should_test_aws,
_should_test_gcp,
_should_test_hdfs,
_should_test_oss,
_should_test_ssh,
Azure,
GDrive,
OSS,
TEST_CONFIG,
TEST_SECTION,
TEST_GCP_CREDS_FILE,
Expand All @@ -48,7 +48,6 @@
get_gcp_url,
get_hdfs_url,
get_local_url,
get_oss_url,
get_ssh_url,
get_ssh_url_mocked,
)
Expand Down Expand Up @@ -273,10 +272,10 @@ def _get_cloud_class(self):

class TestRemoteOSS(TestDataCloudBase):
def _should_test(self):
return _should_test_oss()
return OSS.should_test()

def _get_url(self):
return get_oss_url()
return OSS.get_url()

def _get_cloud_class(self):
return RemoteOSS
Expand Down Expand Up @@ -545,10 +544,10 @@ def _test(self):

class TestRemoteOSSCLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_oss()
return OSS.should_test()

def _test(self):
url = get_oss_url()
url = OSS.get_url()

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

Expand Down
41 changes: 19 additions & 22 deletions tests/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ def _should_test_gcp():
return True


def _should_test_oss():
do_test = env2bool("DVC_TEST_OSS", undefined=None)
if do_test is not None:
return do_test

return (
os.getenv("OSS_ENDPOINT")
and os.getenv("OSS_ACCESS_KEY_ID")
and os.getenv("OSS_ACCESS_KEY_SECRET")
)


def _should_test_ssh():
do_test = env2bool("DVC_TEST_SSH", undefined=None)
if do_test is not None:
Expand Down Expand Up @@ -184,14 +172,6 @@ def get_gcp_url():
return "gs://" + get_gcp_storagepath()


def get_oss_storagepath():
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))


def get_oss_url():
return "oss://{}".format(get_oss_storagepath())


# NOTE: staticmethod is only needed in Python 2
class Local:
should_test = staticmethod(lambda: True)
Expand Down Expand Up @@ -270,8 +250,25 @@ def get_url():


class OSS:
should_test = staticmethod(_should_test_oss)
get_url = staticmethod(get_oss_url)
@staticmethod
def should_test():
do_test = env2bool("DVC_TEST_OSS", undefined=None)
if do_test is not None:
return do_test

return (
os.getenv("OSS_ENDPOINT")
and os.getenv("OSS_ACCESS_KEY_ID")
and os.getenv("OSS_ACCESS_KEY_SECRET")
)

@staticmethod
def get_storagepath():
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))

@staticmethod
def get_url():
return "oss://{}".format(OSS.get_storagepath())


class SSH:
Expand Down