mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
test: merge _should_oss_azure and _get_oss_url inside OSS class
This commit is contained in:
@@ -34,10 +34,10 @@ from tests.remotes import (
|
||||
_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 @@ from tests.remotes import (
|
||||
get_gcp_url,
|
||||
get_hdfs_url,
|
||||
get_local_url,
|
||||
get_oss_url,
|
||||
get_ssh_url,
|
||||
get_ssh_url_mocked,
|
||||
)
|
||||
@@ -273,10 +272,10 @@ class TestRemoteAZURE(TestDataCloudBase):
|
||||
|
||||
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 @@ class TestRemoteAZURECLI(TestDataCloudCLIBase):
|
||||
|
||||
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])
|
||||
|
||||
|
||||
+19
-22
@@ -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 @@ class Azure:
|
||||
|
||||
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user