From 96c87d5643f4d8a8a1fa1b0dfc984fda47c001de Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Sat, 4 Jan 2020 19:27:06 +0545 Subject: [PATCH] test: merge _should_oss_azure and _get_oss_url inside OSS class --- tests/func/test_data_cloud.py | 11 +++++----- tests/remotes.py | 41 ++++++++++++++++------------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/tests/func/test_data_cloud.py b/tests/func/test_data_cloud.py index c9eee21b5f..2d8be3538b 100644 --- a/tests/func/test_data_cloud.py +++ b/tests/func/test_data_cloud.py @@ -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, @@ -48,7 +48,6 @@ get_gcp_url, get_hdfs_url, get_local_url, - get_oss_url, get_ssh_url, get_ssh_url_mocked, ) @@ -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 @@ -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]) diff --git a/tests/remotes.py b/tests/remotes.py index f2623b2d41..88093f30fb 100644 --- a/tests/remotes.py +++ b/tests/remotes.py @@ -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: @@ -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) @@ -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: