fix: use getContent() instead of get() for Apps Script file retrieval

projects().get() only returns project metadata (title, scriptId, dates),
not file contents. This caused get_script_project to always show an empty
files list and get_script_content to return "File not found" for
container-bound scripts.

The correct method is projects().getContent() which maps to
GET /v1/projects/{scriptId}/content and returns all files with
their source code.

Fixes #441

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Leandro3996
2026-02-09 13:47:21 -03:00
parent 6c32126796
commit 2af9ced64d
2 changed files with 21 additions and 6 deletions

View File

@@ -62,12 +62,19 @@ async def test_list_script_projects():
async def test_get_script_project():
"""Test retrieving complete project details"""
mock_service = Mock()
mock_response = {
# projects().get() returns metadata only (no files)
mock_metadata_response = {
"scriptId": "test123",
"title": "Test Project",
"creator": {"email": "creator@example.com"},
"createTime": "2025-01-10T10:00:00Z",
"updateTime": "2026-01-12T15:30:00Z",
}
# projects().getContent() returns files with source code
mock_content_response = {
"scriptId": "test123",
"files": [
{
"name": "Code",
@@ -77,7 +84,8 @@ async def test_get_script_project():
],
}
mock_service.projects().get().execute.return_value = mock_response
mock_service.projects().get().execute.return_value = mock_metadata_response
mock_service.projects().getContent().execute.return_value = mock_content_response
result = await _get_script_project_impl(
service=mock_service, user_google_email="test@example.com", script_id="test123"