mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-24 23:09:33 +01:00
Merge pull request #3055 from skshetry/refactor-remote-azure
test: Merge _should_test_azure and _get_azure_url inside Azure test helper
This commit is contained in:
@@ -32,11 +32,11 @@ from tests.utils import spy
|
||||
|
||||
from tests.remotes import (
|
||||
_should_test_aws,
|
||||
_should_test_azure,
|
||||
_should_test_gcp,
|
||||
_should_test_hdfs,
|
||||
_should_test_oss,
|
||||
_should_test_ssh,
|
||||
Azure,
|
||||
GDrive,
|
||||
TEST_CONFIG,
|
||||
TEST_SECTION,
|
||||
@@ -45,7 +45,6 @@ from tests.remotes import (
|
||||
TEST_GDRIVE_CLIENT_SECRET,
|
||||
TEST_REMOTE,
|
||||
get_aws_url,
|
||||
get_azure_url,
|
||||
get_gcp_url,
|
||||
get_hdfs_url,
|
||||
get_local_url,
|
||||
@@ -263,10 +262,10 @@ class TestRemoteGS(TestDataCloudBase):
|
||||
|
||||
class TestRemoteAZURE(TestDataCloudBase):
|
||||
def _should_test(self):
|
||||
return _should_test_azure()
|
||||
return Azure.should_test()
|
||||
|
||||
def _get_url(self):
|
||||
return get_azure_url()
|
||||
return Azure.get_url()
|
||||
|
||||
def _get_cloud_class(self):
|
||||
return RemoteAZURE
|
||||
@@ -534,10 +533,10 @@ class TestRemoteGSCLI(TestDataCloudCLIBase):
|
||||
|
||||
class TestRemoteAZURECLI(TestDataCloudCLIBase):
|
||||
def _should_test(self):
|
||||
return _should_test_azure()
|
||||
return Azure.should_test()
|
||||
|
||||
def _test(self):
|
||||
url = get_azure_url()
|
||||
url = Azure.get_url()
|
||||
|
||||
self.main(["remote", "add", TEST_REMOTE, url])
|
||||
|
||||
|
||||
+15
-18
@@ -77,16 +77,6 @@ def _should_test_gcp():
|
||||
return True
|
||||
|
||||
|
||||
def _should_test_azure():
|
||||
do_test = env2bool("DVC_TEST_AZURE", undefined=None)
|
||||
if do_test is not None:
|
||||
return do_test
|
||||
|
||||
return os.getenv("AZURE_STORAGE_CONTAINER_NAME") and os.getenv(
|
||||
"AZURE_STORAGE_CONNECTION_STRING"
|
||||
)
|
||||
|
||||
|
||||
def _should_test_oss():
|
||||
do_test = env2bool("DVC_TEST_OSS", undefined=None)
|
||||
if do_test is not None:
|
||||
@@ -194,12 +184,6 @@ def get_gcp_url():
|
||||
return "gs://" + get_gcp_storagepath()
|
||||
|
||||
|
||||
def get_azure_url():
|
||||
container_name = os.getenv("AZURE_STORAGE_CONTAINER_NAME")
|
||||
assert container_name is not None
|
||||
return "azure://{}/{}".format(container_name, str(uuid.uuid4()))
|
||||
|
||||
|
||||
def get_oss_storagepath():
|
||||
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))
|
||||
|
||||
@@ -268,8 +252,21 @@ class GDrive:
|
||||
|
||||
|
||||
class Azure:
|
||||
should_test = staticmethod(_should_test_azure)
|
||||
get_url = staticmethod(get_azure_url)
|
||||
@staticmethod
|
||||
def should_test():
|
||||
do_test = env2bool("DVC_TEST_AZURE", undefined=None)
|
||||
if do_test is not None:
|
||||
return do_test
|
||||
|
||||
return os.getenv("AZURE_STORAGE_CONTAINER_NAME") and os.getenv(
|
||||
"AZURE_STORAGE_CONNECTION_STRING"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_url():
|
||||
container_name = os.getenv("AZURE_STORAGE_CONTAINER_NAME")
|
||||
assert container_name is not None
|
||||
return "azure://{}/{}".format(container_name, str(uuid.uuid4()))
|
||||
|
||||
|
||||
class OSS:
|
||||
|
||||
Reference in New Issue
Block a user