Skip to content

Commit 96c87d5

Browse files
committed
test: merge _should_oss_azure and _get_oss_url inside OSS class
1 parent 54faf1b commit 96c87d5

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

tests/func/test_data_cloud.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
_should_test_aws,
3535
_should_test_gcp,
3636
_should_test_hdfs,
37-
_should_test_oss,
3837
_should_test_ssh,
3938
Azure,
4039
GDrive,
40+
OSS,
4141
TEST_CONFIG,
4242
TEST_SECTION,
4343
TEST_GCP_CREDS_FILE,
@@ -48,7 +48,6 @@
4848
get_gcp_url,
4949
get_hdfs_url,
5050
get_local_url,
51-
get_oss_url,
5251
get_ssh_url,
5352
get_ssh_url_mocked,
5453
)
@@ -273,10 +272,10 @@ def _get_cloud_class(self):
273272

274273
class TestRemoteOSS(TestDataCloudBase):
275274
def _should_test(self):
276-
return _should_test_oss()
275+
return OSS.should_test()
277276

278277
def _get_url(self):
279-
return get_oss_url()
278+
return OSS.get_url()
280279

281280
def _get_cloud_class(self):
282281
return RemoteOSS
@@ -545,10 +544,10 @@ def _test(self):
545544

546545
class TestRemoteOSSCLI(TestDataCloudCLIBase):
547546
def _should_test(self):
548-
return _should_test_oss()
547+
return OSS.should_test()
549548

550549
def _test(self):
551-
url = get_oss_url()
550+
url = OSS.get_url()
552551

553552
self.main(["remote", "add", TEST_REMOTE, url])
554553

tests/remotes.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ def _should_test_gcp():
7777
return True
7878

7979

80-
def _should_test_oss():
81-
do_test = env2bool("DVC_TEST_OSS", undefined=None)
82-
if do_test is not None:
83-
return do_test
84-
85-
return (
86-
os.getenv("OSS_ENDPOINT")
87-
and os.getenv("OSS_ACCESS_KEY_ID")
88-
and os.getenv("OSS_ACCESS_KEY_SECRET")
89-
)
90-
91-
9280
def _should_test_ssh():
9381
do_test = env2bool("DVC_TEST_SSH", undefined=None)
9482
if do_test is not None:
@@ -184,14 +172,6 @@ def get_gcp_url():
184172
return "gs://" + get_gcp_storagepath()
185173

186174

187-
def get_oss_storagepath():
188-
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))
189-
190-
191-
def get_oss_url():
192-
return "oss://{}".format(get_oss_storagepath())
193-
194-
195175
# NOTE: staticmethod is only needed in Python 2
196176
class Local:
197177
should_test = staticmethod(lambda: True)
@@ -270,8 +250,25 @@ def get_url():
270250

271251

272252
class OSS:
273-
should_test = staticmethod(_should_test_oss)
274-
get_url = staticmethod(get_oss_url)
253+
@staticmethod
254+
def should_test():
255+
do_test = env2bool("DVC_TEST_OSS", undefined=None)
256+
if do_test is not None:
257+
return do_test
258+
259+
return (
260+
os.getenv("OSS_ENDPOINT")
261+
and os.getenv("OSS_ACCESS_KEY_ID")
262+
and os.getenv("OSS_ACCESS_KEY_SECRET")
263+
)
264+
265+
@staticmethod
266+
def get_storagepath():
267+
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))
268+
269+
@staticmethod
270+
def get_url():
271+
return "oss://{}".format(OSS.get_storagepath())
275272

276273

277274
class SSH:

0 commit comments

Comments
 (0)