ruff.toml has declared `quote-style = "single"` and line-length 120 since the lint job landed, and 118 of 128 files follow it. The panel backend and the netbox configuration were written in black/prettier style instead, so a `ruff format --check` would have failed on them from the start. Bring them onto the style the repository already declares, which is what makes the check adoptable at all. Formatting only: apart from quote style the diff is multi-line expressions joined where they fit inside 120 columns. Both suites still pass afterwards (25 pytest, and ruff check is clean). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import pytest
|
|
from app.main import validation_error_handler
|
|
from app.models import AccountBase, DeleteRequest
|
|
from fastapi.exceptions import RequestValidationError
|
|
from pydantic import ValidationError
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
'instance_id',
|
|
['Upper', 'has_space', '-leading', 'trailing-', 'x' * 41],
|
|
)
|
|
def test_invalid_instance_ids(instance_id: str) -> None:
|
|
with pytest.raises(ValidationError):
|
|
AccountBase(
|
|
instance_id=instance_id,
|
|
display_name='Test',
|
|
api_id=1,
|
|
api_hash='0123456789abcdef',
|
|
)
|
|
|
|
|
|
def test_delete_data_defaults_to_false() -> None:
|
|
request = DeleteRequest(confirmation='test')
|
|
assert request.delete_data is False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_validation_response_does_not_echo_secret_input() -> None:
|
|
sensitive_value = '-'.join(('very', 'private', 'string', 'session'))
|
|
error = RequestValidationError(
|
|
[
|
|
{
|
|
'type': 'string_too_short',
|
|
'loc': ('body', 'session_string'),
|
|
'msg': 'String should have at least 32 characters',
|
|
'input': sensitive_value,
|
|
}
|
|
]
|
|
)
|
|
|
|
response = await validation_error_handler(None, error)
|
|
|
|
assert sensitive_value.encode() not in response.body
|
|
assert b'"input"' not in response.body
|