def gdrive(test_config, make_tmp_dir): test_config.requires("gdrive") 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()) fs = GDriveFileSystem(tmp_dir.dvc, ret.config) fs._gdrive_create_dir("root", fs.path_info.path) yield ret
def _make_gdrive(): # NOTE: temporary workaround tmp_dir = make_tmp_dir("gdrive", dvc=True) ret = GDrive(GDrive.get_url()) fs = GDriveFileSystem(gdrive_credentials_tmp_dir=tmp_dir.dvc.tmp_dir, **ret.config) fs.fs._gdrive_create_dir("root", fs.url) yield ret
def test_drive(self, dvc, monkeypatch): fs = GDriveFileSystem(gdrive_credentials_tmp_dir=dvc.tmp_dir, **self.CONFIG) monkeypatch.setenv( GDriveFileSystem.GDRIVE_CREDENTIALS_DATA, USER_CREDS_TOKEN_REFRESH_ERROR, ) with pytest.raises(GDriveAuthError): assert fs.fs monkeypatch.setenv(GDriveFileSystem.GDRIVE_CREDENTIALS_DATA, "") fs = GDriveFileSystem(gdrive_credentials_tmp_dir=dvc.tmp_dir, **self.CONFIG) monkeypatch.setenv( GDriveFileSystem.GDRIVE_CREDENTIALS_DATA, USER_CREDS_MISSED_KEY_ERROR, ) with pytest.raises(GDriveAuthError): assert fs.fs
def test_init(self, dvc): fs = GDriveFileSystem(gdrive_credentials_tmp_dir=dvc.tmp_dir, **self.CONFIG) assert str(fs.path_info) == self.CONFIG["url"]
def test_service_account_using_env_var(self, dvc, monkeypatch): monkeypatch.setenv(GDriveFileSystem.GDRIVE_CREDENTIALS_DATA, "foo") GDriveFileSystem(gdrive_credentials_tmp_dir=dvc.tmp_dir, gdrive_use_service_account=True, **self.CONFIG)