Skip to content

Commit

Permalink
Merge pull request #3056 from skshetry/refactor-gdrive
Browse files Browse the repository at this point in the history
test: add _should_test_gdrive and _get_gdrive_url inside GDrive
  • Loading branch information
efiop authored Jan 4, 2020
2 parents f39d8eb + c0616fc commit b6c77f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
11 changes: 5 additions & 6 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
_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,
Expand All @@ -47,7 +47,6 @@
get_aws_url,
get_azure_url,
get_gcp_url,
get_gdrive_url,
get_hdfs_url,
get_local_url,
get_oss_url,
Expand Down Expand Up @@ -209,7 +208,7 @@ def _get_cloud_class(self):

class TestRemoteGDrive(TestDataCloudBase):
def _should_test(self):
return _should_test_gdrive()
return GDrive.should_test()

def _setup_cloud(self):
self._ensure_should_run()
Expand All @@ -230,7 +229,7 @@ def _setup_cloud(self):
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
Expand Down Expand Up @@ -484,10 +483,10 @@ def _test(self):

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(
Expand Down
21 changes: 10 additions & 11 deletions tests/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -268,6 +257,16 @@ def put_objects(remote, objects):
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)
Expand Down

0 comments on commit b6c77f7

Please sign in to comment.