Skip to content

Commit 54faf1b

Browse files
authored
Merge pull request #3055 from skshetry/refactor-remote-azure
test: Merge _should_test_azure and _get_azure_url inside Azure test helper
2 parents b6c77f7 + 60e5121 commit 54faf1b

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

tests/func/test_data_cloud.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232

3333
from tests.remotes import (
3434
_should_test_aws,
35-
_should_test_azure,
3635
_should_test_gcp,
3736
_should_test_hdfs,
3837
_should_test_oss,
3938
_should_test_ssh,
39+
Azure,
4040
GDrive,
4141
TEST_CONFIG,
4242
TEST_SECTION,
@@ -45,7 +45,6 @@
4545
TEST_GDRIVE_CLIENT_SECRET,
4646
TEST_REMOTE,
4747
get_aws_url,
48-
get_azure_url,
4948
get_gcp_url,
5049
get_hdfs_url,
5150
get_local_url,
@@ -263,10 +262,10 @@ def _get_cloud_class(self):
263262

264263
class TestRemoteAZURE(TestDataCloudBase):
265264
def _should_test(self):
266-
return _should_test_azure()
265+
return Azure.should_test()
267266

268267
def _get_url(self):
269-
return get_azure_url()
268+
return Azure.get_url()
270269

271270
def _get_cloud_class(self):
272271
return RemoteAZURE
@@ -534,10 +533,10 @@ def _test(self):
534533

535534
class TestRemoteAZURECLI(TestDataCloudCLIBase):
536535
def _should_test(self):
537-
return _should_test_azure()
536+
return Azure.should_test()
538537

539538
def _test(self):
540-
url = get_azure_url()
539+
url = Azure.get_url()
541540

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

tests/remotes.py

+15-18
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ def _should_test_gcp():
7777
return True
7878

7979

80-
def _should_test_azure():
81-
do_test = env2bool("DVC_TEST_AZURE", undefined=None)
82-
if do_test is not None:
83-
return do_test
84-
85-
return os.getenv("AZURE_STORAGE_CONTAINER_NAME") and os.getenv(
86-
"AZURE_STORAGE_CONNECTION_STRING"
87-
)
88-
89-
9080
def _should_test_oss():
9181
do_test = env2bool("DVC_TEST_OSS", undefined=None)
9282
if do_test is not None:
@@ -194,12 +184,6 @@ def get_gcp_url():
194184
return "gs://" + get_gcp_storagepath()
195185

196186

197-
def get_azure_url():
198-
container_name = os.getenv("AZURE_STORAGE_CONTAINER_NAME")
199-
assert container_name is not None
200-
return "azure://{}/{}".format(container_name, str(uuid.uuid4()))
201-
202-
203187
def get_oss_storagepath():
204188
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))
205189

@@ -268,8 +252,21 @@ def get_url():
268252

269253

270254
class Azure:
271-
should_test = staticmethod(_should_test_azure)
272-
get_url = staticmethod(get_azure_url)
255+
@staticmethod
256+
def should_test():
257+
do_test = env2bool("DVC_TEST_AZURE", undefined=None)
258+
if do_test is not None:
259+
return do_test
260+
261+
return os.getenv("AZURE_STORAGE_CONTAINER_NAME") and os.getenv(
262+
"AZURE_STORAGE_CONNECTION_STRING"
263+
)
264+
265+
@staticmethod
266+
def get_url():
267+
container_name = os.getenv("AZURE_STORAGE_CONTAINER_NAME")
268+
assert container_name is not None
269+
return "azure://{}/{}".format(container_name, str(uuid.uuid4()))
273270

274271

275272
class OSS:

0 commit comments

Comments
 (0)