mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
* dvc: get rid of is_walking_tree No longer needed. Some applications of `isinstance()` will be refactored in the future, as trees will just provide the needed functionality. * dvc: move GitTree to dvc/tree/ * dvc: rename *RemoteTree to *Tree
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
# pylint:disable=abstract-method
|
|
import os
|
|
import uuid
|
|
|
|
import pytest
|
|
from funcy import cached_property
|
|
|
|
from dvc.path_info import CloudURLInfo
|
|
from dvc.tree.gdrive import GDriveTree
|
|
|
|
from .base import Base
|
|
|
|
TEST_GDRIVE_REPO_BUCKET = "root"
|
|
|
|
|
|
class GDrive(Base, CloudURLInfo):
|
|
@staticmethod
|
|
def should_test():
|
|
return os.getenv(GDriveTree.GDRIVE_CREDENTIALS_DATA) is not None
|
|
|
|
@cached_property
|
|
def config(self):
|
|
return {
|
|
"url": self.url,
|
|
"gdrive_service_account_email": "test",
|
|
"gdrive_service_account_p12_file_path": "test.p12",
|
|
"gdrive_use_service_account": True,
|
|
}
|
|
|
|
@staticmethod
|
|
def _get_storagepath():
|
|
return TEST_GDRIVE_REPO_BUCKET + "/" + str(uuid.uuid4())
|
|
|
|
@staticmethod
|
|
def get_url():
|
|
# NOTE: `get_url` should always return new random url
|
|
return "gdrive://" + GDrive._get_storagepath()
|
|
|
|
|
|
@pytest.fixture
|
|
def gdrive(make_tmp_dir):
|
|
if not GDrive.should_test():
|
|
pytest.skip("no gdrive")
|
|
|
|
# NOTE: temporary workaround
|
|
tmp_dir = make_tmp_dir("gdrive", dvc=True)
|
|
|
|
ret = GDrive(GDrive.get_url())
|
|
tree = GDriveTree(tmp_dir.dvc, ret.config)
|
|
tree._gdrive_create_dir("root", tree.path_info.path)
|
|
return ret
|