style: apply ruff auto-fix

- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2026-02-23 09:33:48 +00:00
parent 7fe25474bb
commit 540541eec6
13 changed files with 193 additions and 550 deletions
+14 -48
View File
@@ -48,9 +48,7 @@ class TestSetupWizardDbPersist:
@patch("app.views.wizard.notify_settings_updated")
@patch("app.views.wizard.save_setting_to_db")
def test_notify_not_called_when_no_settings_saved(
self, mock_save, mock_notify, client
):
def test_notify_not_called_when_no_settings_saved(self, mock_save, mock_notify, client):
"""Test that notify_settings_updated is NOT called when saved_count == 0."""
mock_save.return_value = False
@@ -65,9 +63,7 @@ class TestSetupWizardDbPersist:
@patch("app.views.wizard.notify_settings_updated")
@patch("app.views.wizard.secrets.token_hex")
@patch("app.views.wizard.save_setting_to_db")
def test_auto_generate_session_secret(
self, mock_save, mock_token, mock_notify, client
):
def test_auto_generate_session_secret(self, mock_save, mock_token, mock_notify, client):
"""Test that session_secret auto-generate path produces a real token."""
mock_save.return_value = True
mock_token.return_value = "deadbeef" * 8
@@ -136,9 +132,7 @@ class TestDropboxSaveSettingsDbPersist:
@patch("app.api.dropbox.settings")
@patch("app.api.dropbox.notify_settings_updated")
@patch("app.api.dropbox.save_setting_to_db")
def test_db_written_even_when_env_missing(
self, mock_save, mock_notify, mock_settings, client
):
def test_db_written_even_when_env_missing(self, mock_save, mock_notify, mock_settings, client):
"""Test that DB is written even when .env doesn't exist (no exception)."""
mock_save.return_value = True
@@ -157,9 +151,7 @@ class TestDropboxSaveSettingsDbPersist:
@patch("app.api.dropbox.settings")
@patch("app.api.dropbox.notify_settings_updated")
@patch("app.api.dropbox.save_setting_to_db")
def test_notify_settings_updated_called(
self, mock_save, mock_notify, mock_settings, client
):
def test_notify_settings_updated_called(self, mock_save, mock_notify, mock_settings, client):
"""Test that notify_settings_updated is called."""
mock_save.return_value = True
@@ -175,9 +167,7 @@ class TestDropboxSaveSettingsDbPersist:
@patch("app.api.dropbox.settings")
@patch("app.api.dropbox.notify_settings_updated")
@patch("app.api.dropbox.save_setting_to_db")
def test_all_provided_values_persisted(
self, mock_save, mock_notify, mock_settings, client
):
def test_all_provided_values_persisted(self, mock_save, mock_notify, mock_settings, client):
"""Test that all provided values are persisted to DB."""
mock_save.return_value = True
@@ -212,9 +202,7 @@ class TestGoogleDriveUpdateSettingsDbPersist:
@patch("app.api.google_drive.settings")
@patch("app.api.google_drive.notify_settings_updated")
@patch("app.api.google_drive.save_setting_to_db")
def test_db_written_for_each_provided_field(
self, mock_save, mock_notify, mock_settings, client
):
def test_db_written_for_each_provided_field(self, mock_save, mock_notify, mock_settings, client):
"""Test that DB is written for each provided field."""
mock_save.return_value = True
@@ -241,9 +229,7 @@ class TestGoogleDriveUpdateSettingsDbPersist:
@patch("app.api.google_drive.settings")
@patch("app.api.google_drive.notify_settings_updated")
@patch("app.api.google_drive.save_setting_to_db")
def test_use_oauth_saved_as_lowercase_string(
self, mock_save, mock_notify, mock_settings, client
):
def test_use_oauth_saved_as_lowercase_string(self, mock_save, mock_notify, mock_settings, client):
"""Test that use_oauth is saved as 'true' or 'false' string."""
mock_save.return_value = True
@@ -253,11 +239,7 @@ class TestGoogleDriveUpdateSettingsDbPersist:
follow_redirects=False,
)
use_oauth_calls = [
call
for call in mock_save.call_args_list
if call[0][1] == "google_drive_use_oauth"
]
use_oauth_calls = [call for call in mock_save.call_args_list if call[0][1] == "google_drive_use_oauth"]
assert len(use_oauth_calls) == 1
assert use_oauth_calls[0][0][2] in ("true", "false")
@@ -289,9 +271,7 @@ class TestOneDriveSaveSettingsDbPersist:
@patch("app.api.onedrive.settings")
@patch("app.api.onedrive.notify_settings_updated")
@patch("app.api.onedrive.save_setting_to_db")
def test_db_written_even_without_env_file(
self, mock_save, mock_notify, mock_settings, client
):
def test_db_written_even_without_env_file(self, mock_save, mock_notify, mock_settings, client):
"""Test that DB is written even when .env file does not exist."""
mock_save.return_value = True
@@ -435,9 +415,7 @@ class TestExportEnvEndpoint:
mock_request = MagicMock()
mock_admin = {"id": "admin", "is_admin": True}
result = asyncio.run(
export_env_settings(mock_request, db_session, mock_admin, source="db")
)
result = asyncio.run(export_env_settings(mock_request, db_session, mock_admin, source="db"))
assert result.media_type == "text/plain"
def test_content_disposition_header(self, db_session):
@@ -449,9 +427,7 @@ class TestExportEnvEndpoint:
mock_request = MagicMock()
mock_admin = {"id": "admin", "is_admin": True}
result = asyncio.run(
export_env_settings(mock_request, db_session, mock_admin, source="db")
)
result = asyncio.run(export_env_settings(mock_request, db_session, mock_admin, source="db"))
cd = result.headers.get("content-disposition", "")
assert "attachment" in cd
assert ".env" in cd
@@ -468,11 +444,7 @@ class TestExportEnvEndpoint:
mock_admin = {"id": "admin", "is_admin": True}
with pytest.raises(HTTPException) as exc_info:
asyncio.run(
export_env_settings(
mock_request, db_session, mock_admin, source="invalid"
)
)
asyncio.run(export_env_settings(mock_request, db_session, mock_admin, source="invalid"))
assert exc_info.value.status_code == 400
def test_default_source_is_db(self, db_session):
@@ -497,11 +469,7 @@ class TestExportEnvEndpoint:
mock_request = MagicMock()
mock_admin = {"id": "admin", "is_admin": True}
result = asyncio.run(
export_env_settings(
mock_request, db_session, mock_admin, source="effective"
)
)
result = asyncio.run(export_env_settings(mock_request, db_session, mock_admin, source="effective"))
assert result.media_type == "text/plain"
def test_output_contains_docuelevate_header(self, db_session):
@@ -513,7 +481,5 @@ class TestExportEnvEndpoint:
mock_request = MagicMock()
mock_admin = {"id": "admin", "is_admin": True}
result = asyncio.run(
export_env_settings(mock_request, db_session, mock_admin, source="db")
)
result = asyncio.run(export_env_settings(mock_request, db_session, mock_admin, source="db"))
assert b"DocuElevate" in result.body