mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
* remote, minor: fix parameter method name for consistency * gdrive: cleanup, fix workflow with multiple gdrive remotes * config: resolve gdrive cred file parth, typo fix * grdive: address deepsource warning * gdrive: fix tests after simplifying auth flow * gdrive: address PR review, use backticks where appropriate Co-Authored-By: Jorge Orpinel <[email protected]> * gdrive: exception text improvements Co-Authored-By: Jorge Orpinel <[email protected]> * gdrive: fix exception message Co-Authored-By: Jorge Orpinel <[email protected]> * gdrive: fix root not found exception message Co-Authored-By: Jorge Orpinel <[email protected]> * gdrive: minor warnings/exceptions text improvement * gdrive: add tests for the gdrive_user_credentials_file relative path * gdrive: address review, slightly change text * gdrive: comments -> docstrings, addressing PR review Co-authored-by: Jorge Orpinel <[email protected]>
37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
import pytest
|
|
import os
|
|
|
|
from dvc.remote.gdrive import GDriveRemote, GDriveAuthError
|
|
|
|
USER_CREDS_TOKEN_REFRESH_ERROR = '{"access_token": "", "client_id": "", "client_secret": "", "refresh_token": "", "token_expiry": "", "token_uri": "https://oauth2.googleapis.com/token", "user_agent": null, "revoke_uri": "https://oauth2.googleapis.com/revoke", "id_token": null, "id_token_jwt": null, "token_response": {"access_token": "", "expires_in": 3600, "scope": "https://www.googleapis.com/auth/drive.appdata https://www.googleapis.com/auth/drive", "token_type": "Bearer"}, "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata"], "token_info_uri": "https://oauth2.googleapis.com/tokeninfo", "invalid": true, "_class": "OAuth2Credentials", "_module": "oauth2client.client"}' # noqa: E501
|
|
|
|
USER_CREDS_MISSED_KEY_ERROR = "{}"
|
|
|
|
|
|
class TestRemoteGDrive(object):
|
|
CONFIG = {
|
|
"url": "gdrive://root/data",
|
|
"gdrive_client_id": "client",
|
|
"gdrive_client_secret": "secret",
|
|
}
|
|
|
|
def test_init(self, dvc):
|
|
remote = GDriveRemote(dvc, self.CONFIG)
|
|
assert str(remote.path_info) == self.CONFIG["url"]
|
|
|
|
def test_drive(self, dvc):
|
|
remote = GDriveRemote(dvc, self.CONFIG)
|
|
os.environ[
|
|
GDriveRemote.GDRIVE_CREDENTIALS_DATA
|
|
] = USER_CREDS_TOKEN_REFRESH_ERROR
|
|
with pytest.raises(GDriveAuthError):
|
|
remote._drive
|
|
|
|
os.environ[GDriveRemote.GDRIVE_CREDENTIALS_DATA] = ""
|
|
remote = GDriveRemote(dvc, self.CONFIG)
|
|
os.environ[
|
|
GDriveRemote.GDRIVE_CREDENTIALS_DATA
|
|
] = USER_CREDS_MISSED_KEY_ERROR
|
|
with pytest.raises(GDriveAuthError):
|
|
remote._drive
|