Skip to content

Commit b6c77f7

Browse files
authored
Merge pull request #3056 from skshetry/refactor-gdrive
test: add _should_test_gdrive and _get_gdrive_url inside GDrive
2 parents f39d8eb + c0616fc commit b6c77f7

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
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_azure,
3636
_should_test_gcp,
37-
_should_test_gdrive,
3837
_should_test_hdfs,
3938
_should_test_oss,
4039
_should_test_ssh,
40+
GDrive,
4141
TEST_CONFIG,
4242
TEST_SECTION,
4343
TEST_GCP_CREDS_FILE,
@@ -47,7 +47,6 @@
4747
get_aws_url,
4848
get_azure_url,
4949
get_gcp_url,
50-
get_gdrive_url,
5150
get_hdfs_url,
5251
get_local_url,
5352
get_oss_url,
@@ -209,7 +208,7 @@ def _get_cloud_class(self):
209208

210209
class TestRemoteGDrive(TestDataCloudBase):
211210
def _should_test(self):
212-
return _should_test_gdrive()
211+
return GDrive.should_test()
213212

214213
def _setup_cloud(self):
215214
self._ensure_should_run()
@@ -230,7 +229,7 @@ def _setup_cloud(self):
230229
self.assertIsInstance(self.cloud.get_remote(), self._get_cloud_class())
231230

232231
def _get_url(self):
233-
return get_gdrive_url()
232+
return GDrive.get_url()
234233

235234
def _get_cloud_class(self):
236235
return RemoteGDrive
@@ -484,10 +483,10 @@ def _test(self):
484483

485484
class TestRemoteGDriveCLI(TestDataCloudCLIBase):
486485
def _should_test(self):
487-
return _should_test_gdrive()
486+
return GDrive.should_test()
488487

489488
def _test(self):
490-
url = get_gdrive_url()
489+
url = GDrive.get_url()
491490

492491
self.main(["remote", "add", TEST_REMOTE, url])
493492
self.main(

tests/remotes.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ def _should_test_aws():
5454
return False
5555

5656

57-
def _should_test_gdrive():
58-
if os.getenv(RemoteGDrive.GDRIVE_USER_CREDENTIALS_DATA):
59-
return True
60-
61-
return False
62-
63-
6457
def _should_test_gcp():
6558
do_test = env2bool("DVC_TEST_GCP", undefined=None)
6659
if do_test is not None:
@@ -193,10 +186,6 @@ def get_aws_url():
193186
return "s3://" + get_aws_storagepath()
194187

195188

196-
def get_gdrive_url():
197-
return "gdrive://root/" + str(uuid.uuid4())
198-
199-
200189
def get_gcp_storagepath():
201190
return TEST_GCP_REPO_BUCKET + "/" + str(uuid.uuid4())
202191

@@ -268,6 +257,16 @@ def put_objects(remote, objects):
268257
bucket.blob((remote.path_info / key).path).upload_from_string(body)
269258

270259

260+
class GDrive:
261+
@staticmethod
262+
def should_test():
263+
return os.getenv(RemoteGDrive.GDRIVE_USER_CREDENTIALS_DATA) is not None
264+
265+
@staticmethod
266+
def get_url():
267+
return "gdrive://root/" + str(uuid.uuid4())
268+
269+
271270
class Azure:
272271
should_test = staticmethod(_should_test_azure)
273272
get_url = staticmethod(get_azure_url)

0 commit comments

Comments
 (0)