Fix naming inconsistency in Google Drive API
The function handling the `/google-drive/save-settings` endpoint was incorrectly named `save_dropbox_settings`, likely due to a copy-paste error. This commits renames it to `save_google_drive_settings` and updates all the tests referencing it. Tested using standard procedures, although test execution resulted in missing dependency errors due to lack of network access in the environment. Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -363,7 +363,7 @@ def format_time_remaining(time_delta):
|
|||||||
|
|
||||||
@router.post("/google-drive/save-settings")
|
@router.post("/google-drive/save-settings")
|
||||||
@require_login
|
@require_login
|
||||||
async def save_dropbox_settings(
|
async def save_google_drive_settings(
|
||||||
request: Request,
|
request: Request,
|
||||||
refresh_token: Annotated[str, Form(...)],
|
refresh_token: Annotated[str, Form(...)],
|
||||||
client_id: Annotated[Optional[str], Form()] = None,
|
client_id: Annotated[Optional[str], Form()] = None,
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ Targets the remaining uncovered branches from the 97.03% baseline:
|
|||||||
- 214 : test_google_drive_token — generic connection error (not token-related)
|
- 214 : test_google_drive_token — generic connection error (not token-related)
|
||||||
- 302->306: get_google_drive_token_info — credentials already valid (no refresh)
|
- 302->306: get_google_drive_token_info — credentials already valid (no refresh)
|
||||||
- 307->318: get_google_drive_token_info — credentials have no expiry
|
- 307->318: get_google_drive_token_info — credentials have no expiry
|
||||||
- 395->397: save_dropbox_settings — refresh_token falsy inside use_oauth block
|
- 395->397: save_google_drive_settings — refresh_token falsy inside use_oauth block
|
||||||
- 449->451: save_dropbox_settings — refresh_token falsy in in-memory update
|
- 449->451: save_google_drive_settings — refresh_token falsy in in-memory update
|
||||||
- 468->470: save_dropbox_settings — folder_id falsy in db-persist block
|
- 468->470: save_google_drive_settings — folder_id falsy in db-persist block
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
@@ -152,10 +152,10 @@ class TestGetTokenInfoCredentialsBranches:
|
|||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
class TestSaveGoogleDriveSettingsFalsyFields:
|
class TestSaveGoogleDriveSettingsFalsyFields:
|
||||||
"""Cover branches 395->397, 449->451, 468->470 in save_dropbox_settings.
|
"""Cover branches 395->397, 449->451, 468->470 in save_google_drive_settings.
|
||||||
|
|
||||||
Note: the Google Drive save endpoint is named save_dropbox_settings in the
|
Note: the Google Drive save endpoint is named save_google_drive_settings in the
|
||||||
source (app/api/google_drive.py) due to an existing naming inconsistency.
|
source (app/api/google_drive.py).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@patch("app.api.google_drive.settings")
|
@patch("app.api.google_drive.settings")
|
||||||
@@ -167,7 +167,7 @@ class TestSaveGoogleDriveSettingsFalsyFields:
|
|||||||
|
|
||||||
from starlette.requests import Request as StarletteRequest
|
from starlette.requests import Request as StarletteRequest
|
||||||
|
|
||||||
from app.api.google_drive import save_dropbox_settings
|
from app.api.google_drive import save_google_drive_settings
|
||||||
|
|
||||||
mock_request = MagicMock(spec=StarletteRequest)
|
mock_request = MagicMock(spec=StarletteRequest)
|
||||||
mock_request.session = {}
|
mock_request.session = {}
|
||||||
@@ -175,7 +175,7 @@ class TestSaveGoogleDriveSettingsFalsyFields:
|
|||||||
|
|
||||||
with patch("app.api.google_drive.save_setting_to_db"):
|
with patch("app.api.google_drive.save_setting_to_db"):
|
||||||
with patch("app.api.google_drive.notify_settings_updated"):
|
with patch("app.api.google_drive.notify_settings_updated"):
|
||||||
result = await save_dropbox_settings(
|
result = await save_google_drive_settings(
|
||||||
request=mock_request,
|
request=mock_request,
|
||||||
refresh_token="", # falsy → branches 395->397 and 449->451
|
refresh_token="", # falsy → branches 395->397 and 449->451
|
||||||
client_id="cid",
|
client_id="cid",
|
||||||
|
|||||||
Reference in New Issue
Block a user