test: add _should_test_gdrive and _get_gdrive_url inside GDrive

This commit is contained in:
Saugat Pachhai
2020-01-04 22:03:49 +05:45
parent 85c35f894c
commit c0616fcee2
2 changed files with 15 additions and 17 deletions
+5 -6
View File
@@ -34,10 +34,10 @@ from tests.remotes import (
_should_test_aws,
_should_test_azure,
_should_test_gcp,
_should_test_gdrive,
_should_test_hdfs,
_should_test_oss,
_should_test_ssh,
GDrive,
TEST_CONFIG,
TEST_SECTION,
TEST_GCP_CREDS_FILE,
@@ -47,7 +47,6 @@ from tests.remotes import (
get_aws_url,
get_azure_url,
get_gcp_url,
get_gdrive_url,
get_hdfs_url,
get_local_url,
get_oss_url,
@@ -209,7 +208,7 @@ class TestRemoteS3(TestDataCloudBase):
class TestRemoteGDrive(TestDataCloudBase):
def _should_test(self):
return _should_test_gdrive()
return GDrive.should_test()
def _setup_cloud(self):
self._ensure_should_run()
@@ -230,7 +229,7 @@ class TestRemoteGDrive(TestDataCloudBase):
self.assertIsInstance(self.cloud.get_remote(), self._get_cloud_class())
def _get_url(self):
return get_gdrive_url()
return GDrive.get_url()
def _get_cloud_class(self):
return RemoteGDrive
@@ -484,10 +483,10 @@ class TestRemoteS3CLI(TestDataCloudCLIBase):
class TestRemoteGDriveCLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_gdrive()
return GDrive.should_test()
def _test(self):
url = get_gdrive_url()
url = GDrive.get_url()
self.main(["remote", "add", TEST_REMOTE, url])
self.main(
+10 -11
View File
@@ -54,13 +54,6 @@ def _should_test_aws():
return False
def _should_test_gdrive():
if os.getenv(RemoteGDrive.GDRIVE_USER_CREDENTIALS_DATA):
return True
return False
def _should_test_gcp():
do_test = env2bool("DVC_TEST_GCP", undefined=None)
if do_test is not None:
@@ -193,10 +186,6 @@ def get_aws_url():
return "s3://" + get_aws_storagepath()
def get_gdrive_url():
return "gdrive://root/" + str(uuid.uuid4())
def get_gcp_storagepath():
return TEST_GCP_REPO_BUCKET + "/" + str(uuid.uuid4())
@@ -270,6 +259,16 @@ class GCP:
bucket.blob((remote.path_info / key).path).upload_from_string(body)
class GDrive:
@staticmethod
def should_test():
return os.getenv(RemoteGDrive.GDRIVE_USER_CREDENTIALS_DATA) is not None
@staticmethod
def get_url():
return "gdrive://root/" + str(uuid.uuid4())
class Azure:
should_test = staticmethod(_should_test_azure)
get_url = staticmethod(get_azure_url)