Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,22 @@ def _get_cloud_class(self):
return S3Remote


def setup_gdrive_cloud(remote_url, dvc):
config = copy.deepcopy(TEST_CONFIG)
config["remote"][TEST_REMOTE] = {
"url": remote_url,
"gdrive_service_account_email": "test",
"gdrive_service_account_p12_file_path": "test.p12",
"gdrive_use_service_account": True,
}

dvc.config = config
remote = DataCloud(dvc).get_remote()
remote._gdrive_create_dir("root", remote.path_info.path)


class TestGDriveRemote(GDrive, TestDataCloudBase):
def _setup_cloud(self):
self._ensure_should_run()

setup_gdrive_cloud(self.get_url(), self.dvc)
url = self.get_url()
self.create_dir(self.dvc, url)

config = copy.deepcopy(TEST_CONFIG)
config["remote"][TEST_REMOTE] = {
"url": url,
"gdrive_service_account_email": "test",
"gdrive_service_account_p12_file_path": "test.p12",
"gdrive_use_service_account": True,
}

self.dvc.config = config
self.cloud = DataCloud(self.dvc)
remote = self.cloud.get_remote()
self.assertIsInstance(remote, self._get_cloud_class())
Expand Down Expand Up @@ -421,20 +417,19 @@ def _test(self):


class TestGDriveRemoteCLI(GDrive, TestDataCloudCLIBase):
def _setup_cloud(self):
setup_gdrive_cloud(self.get_url(), self.dvc)

def _test(self):
url = self.get_url()

self.create_dir(self.dvc, url)

self.main(["remote", "add", TEST_REMOTE, url])
self.main(
[
"remote",
"modify",
TEST_REMOTE,
"gdrive_service_account_email",
"modified",
"test",
]
)
self.main(
Expand All @@ -443,7 +438,7 @@ def _test(self):
"modify",
TEST_REMOTE,
"gdrive_service_account_p12_file_path",
"modified.p12",
"test.p12",
]
)
self.main(
Expand Down
19 changes: 15 additions & 4 deletions tests/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,21 @@ class GDrive:
def should_test():
return os.getenv(GDriveRemote.GDRIVE_CREDENTIALS_DATA) is not None

def get_url(self):
if not getattr(self, "_remote_url", None):
self._remote_url = "gdrive://root/" + str(uuid.uuid4())
return self._remote_url
@staticmethod
def create_dir(dvc, url):
config = {
"url": url,
"gdrive_service_account_email": "test",
"gdrive_service_account_p12_file_path": "test.p12",
"gdrive_use_service_account": True,
}
remote = GDriveRemote(dvc, config)
remote._gdrive_create_dir("root", remote.path_info.path)

@staticmethod
def get_url():
# NOTE: `get_url` should always return new random url
return "gdrive://root/" + str(uuid.uuid4())


class Azure:
Expand Down