Skip to content
9 changes: 8 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ jobs:
tests:
timeout-minutes: 45
runs-on: ${{ matrix.os }}
environment:
name: env1

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
pyv: ["3.10", "3.11", "3.12", "3.13", "3.14"]
pyv: ["3.13"]

steps:
- uses: actions/checkout@v3
Expand All @@ -38,9 +41,13 @@ jobs:
run: |
pip install --upgrade pip wheel
pip install -e . pytest
pip list

- name: run tests
timeout-minutes: 15
env:
GDRIVE_FSSPEC_DRIVE: gdrivefs-testing
GDRIVE_FSSPEC_CREDENTIALS_PATH: ${{ secrets.GDRIVE_FSSPEC_CREDENTIALS_PATH }}
run: pytest -vv

lint:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ See ``GoogleDriveFileSystem`` docstring for more details.
### Running tests

The tests require defining the following environment variables:
- gdrive_fsspec_CREDENTIALS_PATH: location of a credentials.json
- gdrive_fsspec_CREDENTIALS_PATH: location of a credentials.json or the json blob itself
(starting with "{")
- gdrive_fsspec_CREDENTIALS_TYPE: token type ("service_account" default)
- gdrive_fsspec_DRIVE: shared drive to use.

Expand Down
7 changes: 5 additions & 2 deletions gdrive_fsspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ def _connect_cache(self):

def _connect_service_account(self):
if isinstance(self.creds, str):
creds = json.load(open(self.creds))
if self.creds[0] != "{":
creds = json.load(open(self.creds))
else:
creds = json.loads(self.creds)
else:
creds = self.creds
return service_account.Credentials.from_service_account_info(
Expand Down Expand Up @@ -212,7 +215,7 @@ def rm_file(self, path, file_id=None):
listing = self.dircache[par]
i = [i for i, li in enumerate(listing) if li["name"] == path][0]
listing.pop(i)
self.dircache.pop(path)
self.dircache.pop(path, None)

def rm(self, path, recursive=True, maxdepth=None):
if recursive is False and self.isdir(path) and self.ls(path):
Expand Down
6 changes: 3 additions & 3 deletions gdrive_fsspec/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

testdir = "gdrive_fsspec_testdir"
kwargs = {
"creds": os.getenv("gdrive_fsspec_CREDENTIALS_PATH"),
"token": os.getenv("gdrive_fsspec_CREDENTIALS_TYPE", "service_account"),
"drive": os.getenv("gdrive_fsspec_DRIVE"),
"creds": os.getenv("GDRIVE_FSSPEC_CREDENTIALS_PATH"),
"token": os.getenv("GDRIVE_FSSPEC_CREDENTIALS_TYPE", "service_account"),
"drive": os.getenv("GDRIVE_FSSPEC_DRIVE"),
}


Expand Down