Skip to content

Test the filesystem on the app data folder against real Drive - #463

Draft
shcheklein wants to merge 2 commits into
mainfrom
live-app-data
Draft

shcheklein wants to merge 2 commits into
mainfrom
live-app-data

Conversation

@shcheklein

@shcheklein shcheklein commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

A filesystem can be opened on the app data folder, the hidden per-app folder in a user's Drive:

fs = GDriveFileSystem("appDataFolder", use_service_account=True, client_json=key)
fs.pipe_file("appDataFolder/state/model.bin", data)

Its code differs from the rest of the filesystem: every listing asks Drive for the appDataFolder space, new IDs are generated for that space, and removing a folder checks the app data scope. Only mocks tested any of it. This adds two live tests on real Drive, in test_fs.py. They share one service-account login with the drive.appdata scope. Each works in its own folder under appDataFolder and reads back with a new filesystem instance.

  • Writes and reads: makedirs, pipe_file, cp_file and mv, then ls of the app data folder and of the test folder, detailed find, info and cat_file. Sizes and MD5 checksums equal those of the bytes written.
  • Removal with trash_only=False: rmdir of a folder that holds a file raises ENOTEMPTY and leaves the file; after rm_file, rmdir removes the folder. The emptiness check in app data needs the drive.appdata scope and must query the app data space, so a check sent to the ordinary space would fail the first step.

Not covered here: removal with the default trash_only=True

Drive cannot trash files in the app data folder. It answers 403 notSupportedForAppDataFolderFiles ("Files within the Application Data folder cannot be trashed", Drive guide). The filesystem trashes by default and has no case for app data, so fs.rm_file("appDataFolder/...") with default options should raise an ApiRequestError. What it should do instead needs a decision, and the fix will come with its own live test. These tests remove with trash_only=False, and their cleanup deletes the test folder by ID.

Validation

Test-only change. The tests pass against the local fake Drive as a smoke check, after teaching the fake the appDataFolder alias. They are expected to pass on real Drive. If one fails, it has found a bug, and the fix goes in its own PR.

🤖 Generated with Claude Code

Writes, reads, copies, moves and permanent removal under appDataFolder,
which only mocks covered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pydrive2/test/test_fs_app_data.py Resolved
Comment thread pydrive2/test/test_fs_app_data.py Resolved

@shcheklein shcheklein left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI generated — Copilot]

5-pass review summary: clean functional live tests with zero monkeypatching/internals. Two things to improve: avoid 8 redundant OAuth token exchanges across 2 tests, and place these 2 tests in test_fs.py rather than adding a 64-line standalone module.

Comment thread pydrive2/test/test_fs_app_data.py Resolved
Comment thread pydrive2/test/test_fs_app_data.py Resolved
@shcheklein shcheklein mentioned this pull request Dec 3, 2026
1 of 2 tasks
One module-scoped login covers the app data scope, the test folder is
created and deleted by ID, and rmdir first refuses a folder that still
holds a file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the added app-data filesystem integration tests.

No open issues 🎉

What changed in this PR

Adds live integration tests for the filesystem’s hidden Drive app data folder, without changing production code.

Changes:

  • Adds shared authentication and isolated test folders with permanent cleanup.
  • Verifies writes, copies, moves, listings, content, and metadata through a fresh filesystem instance.
  • Checks that permanent folder removal refuses nonempty folders and succeeds after their contents are deleted.
File Description
pydrive2/​test/​test_fs.py Adds app data fixtures and two live filesystem tests.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants