Merge pull request #2435 from infinito-nexus/fix/main/quality-high-lints

fix: restore make quality-high on main (merge test fixtures, adapter file size)
This commit is contained in:
kevinveenbirkenbach authored and GitHub committed 2026-11-21 12:03:17 +01:00
commit 71d74e44cc
6 files changed
+41 -13

No files matched your search

@@ -391,6 +391,23 @@ def authorize_call(
return method, str(spec["path"])
def request_length(header: str | None) -> int:
"""
Args:
header: the raw ``Content-Length`` value, ``None`` when the client sent
none.
Returns:
the announced body size in bytes; ``0`` without a header, since RFC 9112
reads such a request as bodiless; a negative number when the value is
negative or no integer.
"""
try:
return int(header or 0)
except ValueError:
return -1
def clamp_page(contract: Mapping[str, Any], requested: Any) -> int:
"""Return a page size no larger than the contract allows.
@@ -413,10 +413,7 @@ class Handler(BaseHTTPRequestHandler):
self._respond(401, {"error": policy.DENY_UNAUTHENTICATED})
return
try:
length = int(self.headers.get("Content-Length") or 0)
except ValueError:
length = -1
length = policy.request_length(self.headers.get("Content-Length"))
if length < 0:
self._respond(400, {"error": "invalid_content_length"})
return
@@ -3,6 +3,7 @@ from __future__ import annotations
import unittest
from cli.contributing.update.merge import gate
from utils.roles.mapping import ROLE_FILE_META_SERVICES
REPO = "infinito-nexus/core"
@@ -24,7 +25,7 @@ def check(**overrides):
"name": "🧹 Lint",
"status": "completed",
"conclusion": "success",
"details_url": "https://github.com/o/r/actions/runs/1/job/2",
"details_url": "https://github.example/o/r/actions/runs/1/job/2",
}
run.update(overrides)
return run
@@ -75,7 +76,7 @@ class TestCheckRefusals(unittest.TestCase):
)
def test_only_the_own_run_left_refuses(self):
own = check(details_url="https://github.com/o/r/actions/runs/9/job/3")
own = check(details_url="https://github.example/o/r/actions/runs/9/job/3")
self.assertEqual(
gate.check_refusals([own], [], own_run_id=9),
["no check run on the head commit"],
@@ -92,8 +93,8 @@ class TestCheckRefusals(unittest.TestCase):
class TestRoles(unittest.TestCase):
def test_changed_roles_reads_the_role_directory(self):
paths = [
"roles/web-app-nextcloud/meta/services.yml",
"roles/sys-lint/meta/services.yml",
f"roles/web-app-nextcloud/{ROLE_FILE_META_SERVICES}",
f"roles/sys-lint/{ROLE_FILE_META_SERVICES}",
"pyproject.toml",
"docs/roles/web-app-matomo.md",
]
@@ -7,6 +7,7 @@ import zipfile
from unittest.mock import Mock
from cli.contributing.update.merge import github
from utils.roles.mapping import ROLE_FILE_META_MAIN
REPO = "infinito-nexus/core"
SHA = "b" * 40
@@ -43,8 +44,8 @@ class TestReads(unittest.TestCase):
def test_changed_paths_keep_the_old_name_of_a_rename(self):
files = [
{
"filename": "roles/web-app-new/meta/main.yml",
"previous_filename": "roles/web-app-old/meta/main.yml",
"filename": f"roles/web-app-new/{ROLE_FILE_META_MAIN}",
"previous_filename": f"roles/web-app-old/{ROLE_FILE_META_MAIN}",
},
{"filename": "pyproject.toml", "previous_filename": None},
]
@@ -52,8 +53,8 @@ class TestReads(unittest.TestCase):
self.assertEqual(
github.changed_paths(gh, REPO, 5),
[
"roles/web-app-new/meta/main.yml",
"roles/web-app-old/meta/main.yml",
f"roles/web-app-new/{ROLE_FILE_META_MAIN}",
f"roles/web-app-old/{ROLE_FILE_META_MAIN}",
"pyproject.toml",
],
)
@@ -11,6 +11,7 @@ from unittest.mock import patch
import cli.contributing.update.merge.__main__ as merge_main
from cli.contributing.update.merge import github
from utils.roles.mapping import ROLE_FILE_META_SERVICES
REPO = "infinito-nexus/core"
SHA = "a" * 40
@@ -97,7 +98,7 @@ def green_gh(**overrides):
"prs": [pull_request()],
"checks": [check()],
"statuses": [{"context": "codecov", "state": "success"}],
"files": ["roles/web-app-nextcloud/meta/services.yml"],
"files": [f"roles/web-app-nextcloud/{ROLE_FILE_META_SERVICES}"],
"artifacts": {
"role-runtimes-web-app-nextcloud": role_runtimes(
"web-app-nextcloud", "svc-db-postgres"
@@ -212,6 +212,17 @@ class TestLimits(unittest.TestCase):
self.assertEqual(5, len(policy.truncate_results(contract(), list(range(50)))))
class TestRequestLength(unittest.TestCase):
def test_a_missing_header_announces_no_body(self):
self.assertEqual(policy.request_length(None), 0)
def test_a_numeric_header_is_the_byte_count(self):
self.assertEqual(policy.request_length("12"), 12)
def test_a_non_numeric_header_is_negative(self):
self.assertLess(policy.request_length("abc"), 0)
class TestDeclaredArguments(unittest.TestCase):
"""A published input schema is enforced, not merely advertised.