Skip to content

Commit c4783f4

Browse files
committed
test: merge _should_test_azure and _get_azure_url inside Azure class
1 parent 85c35f8 commit c4783f4

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

tests/func/test_data_cloud.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,19 @@
3232

3333
from tests.remotes import (
3434
_should_test_aws,
35-
_should_test_azure,
3635
_should_test_gcp,
3736
_should_test_gdrive,
3837
_should_test_hdfs,
3938
_should_test_oss,
4039
_should_test_ssh,
40+
Azure,
4141
TEST_CONFIG,
4242
TEST_SECTION,
4343
TEST_GCP_CREDS_FILE,
4444
TEST_GDRIVE_CLIENT_ID,
4545
TEST_GDRIVE_CLIENT_SECRET,
4646
TEST_REMOTE,
4747
get_aws_url,
48-
get_azure_url,
4948
get_gcp_url,
5049
get_gdrive_url,
5150
get_hdfs_url,
@@ -264,10 +263,10 @@ def _get_cloud_class(self):
264263

265264
class TestRemoteAZURE(TestDataCloudBase):
266265
def _should_test(self):
267-
return _should_test_azure()
266+
return Azure.should_test()
268267

269268
def _get_url(self):
270-
return get_azure_url()
269+
return Azure.get_url()
271270

272271
def _get_cloud_class(self):
273272
return RemoteAZURE
@@ -535,10 +534,10 @@ def _test(self):
535534

536535
class TestRemoteAZURECLI(TestDataCloudCLIBase):
537536
def _should_test(self):
538-
return _should_test_azure()
537+
return Azure.should_test()
539538

540539
def _test(self):
541-
url = get_azure_url()
540+
url = Azure.get_url()
542541

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

tests/remotes.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ def _should_test_gcp():
8484
return True
8585

8686

87-
def _should_test_azure():
88-
do_test = env2bool("DVC_TEST_AZURE", undefined=None)
89-
if do_test is not None:
90-
return do_test
91-
92-
return os.getenv("AZURE_STORAGE_CONTAINER_NAME") and os.getenv(
93-
"AZURE_STORAGE_CONNECTION_STRING"
94-
)
95-
96-
9787
def _should_test_oss():
9888
do_test = env2bool("DVC_TEST_OSS", undefined=None)
9989
if do_test is not None:
@@ -205,12 +195,6 @@ def get_gcp_url():
205195
return "gs://" + get_gcp_storagepath()
206196

207197

208-
def get_azure_url():
209-
container_name = os.getenv("AZURE_STORAGE_CONTAINER_NAME")
210-
assert container_name is not None
211-
return "azure://{}/{}".format(container_name, str(uuid.uuid4()))
212-
213-
214198
def get_oss_storagepath():
215199
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))
216200

@@ -271,8 +255,21 @@ def put_objects(remote, objects):
271255

272256

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

277274

278275
class OSS:

0 commit comments

Comments
 (0)