Skip to content

Commit c68f588

Browse files
CrispStrobeclaude
andcommitted
fix(ci): clear all 7 pre-existing pytest failures
Picks up where the previous mypy fix (d671910) left off — pytest is now the visible failure surface, with 7 distinct tests red across all 3 Python versions in the matrix. All four root causes are real bugs unrelated to recent feature work, just never noticed because mypy was failing before pytest got a chance to run. 1. webdav_provider.get_content() — auth lookup now happens AFTER the pending-shortcut check. Pending uploads (uuid='pending-...') and missing-uuid resources return io.BytesIO(b"") immediately without touching auth_service. Fixes: test_get_content_returns_empty_for_pending_resource test_get_content_returns_empty_when_no_uuid 2. webdav_server.start() — server_choice validation now runs first. Previously, an invalid choice fell through to provider construction (which calls auth) and surfaced a MissingCredentialsError before reaching the explicit ValueError that the test expects. Moved the {'auto','waitress','cheroot'} check to the top of try-block. Fixes: test_invalid_server_choice_does_not_unbound_local 3. drive._available_memory() — Linux fallback now gated on sys.platform.startswith('linux'). The else-branch read /proc/meminfo for any non-darwin / non-win32 platform, including the synthetic 'unknown-os' that the test patches sys.platform to in order to force the 4 GB fallback. Now only Linux takes that branch; everything else falls through. Fixes: test_available_memory_falls_back_to_4gb_when_all_probes_fail 4. requirements-dev.txt — added `cheroot>=10.0`. tests/test_webdav_server_start_branches.py exercises the cheroot branch in start() via sys.modules injection, but `from cheroot import wsgi` first imports the cheroot package itself, which is not installed on CI (only waitress is in requirements.txt). Adding cheroot to dev requirements makes the test pass without changing production install (CI uses requirements-dev.txt; users still install from requirements.txt). Fixes: test_explicit_cheroot_choice_uses_cheroot test_https_with_cheroot_attempts_ssl_setup test_https_with_cheroot_generates_certs_when_missing Verified locally: $ mypy --no-incremental cli.py services Success: no issues found in 8 source files $ pytest tests/ -q --ignore=tests/test_live_smoke.py ............................. 100% No behaviour change in any happy-path runtime flow — every fix is a control-flow tightening that makes the suite pass without touching the operations the suite was already verifying. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d671910 commit c68f588

4 files changed

Lines changed: 32 additions & 8 deletions

File tree

requirements-dev.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ python-dotenv>=1.0.0
1414
# (rate limiting / eventual consistency). Required for tests/test_live_smoke.py
1515
# to be reliable end-to-end; not used by the main unit suite.
1616
pytest-rerunfailures>=12.0
17+
18+
# Optional WSGI server, alternative to waitress. Production code probes
19+
# both at runtime (services/webdav_server.py) and tests in
20+
# tests/test_webdav_server_start_branches.py exercise the cheroot branch
21+
# explicitly — they need it importable to reach the FakeCherootServer
22+
# stub injected via sys.modules.
23+
cheroot>=10.0

services/drive.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ class MEMORYSTATUSEX(ctypes.Structure):
9898
stat = MEMORYSTATUSEX(dwLength=ctypes.sizeof(MEMORYSTATUSEX))
9999
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
100100
return stat.ullAvailPhys
101-
else:
102-
# Linux / other Unix: read from /proc/meminfo
101+
elif sys.platform.startswith('linux'):
102+
# Read from /proc/meminfo (Linux only — gated explicitly so
103+
# tests that patch sys.platform to a synthetic value can
104+
# exercise the 4 GB fallback below).
103105
with open('/proc/meminfo') as f:
104106
for line in f:
105107
if line.startswith('MemAvailable:'):

services/webdav_provider.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,18 @@ def get_content(self) -> Union[bytes, io.BytesIO]:
309309
try:
310310
from services.drive import drive_service
311311
from services.auth import auth_service
312-
313-
credentials = auth_service.get_auth_details()
314-
user = credentials['user']
315-
mnemonic = user['mnemonic']
316-
312+
313+
# Pending uploads + missing uuids return an empty body without
314+
# touching the auth service (no creds needed for a 0-byte read).
315+
# This also makes get_content() callable from unit tests that
316+
# don't bother mocking auth_service.
317317
file_uuid = self.file_metadata.get('uuid')
318318
if not file_uuid or file_uuid.startswith('pending-'):
319319
return io.BytesIO(b"")
320+
321+
credentials = auth_service.get_auth_details()
322+
user = credentials['user']
323+
mnemonic = user['mnemonic']
320324

321325
print(f"📥 WEBDAV: Downloading file {file_uuid} for streaming...")
322326

services/webdav_server.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,22 @@ def start(self, port: Optional[int] = None, background: bool = False,
136136
Dict with success status, message, and URL
137137
"""
138138
try:
139+
# Validate server_choice up-front, before any auth-requiring
140+
# setup (provider construction reads credentials). An invalid
141+
# server choice should fail with the explicit ValueError below
142+
# regardless of login state — useful when a CI / unit test runs
143+
# without credentials.
144+
if server_choice not in ('auto', 'waitress', 'cheroot'):
145+
raise ValueError(
146+
f"Unknown server choice '{server_choice}'. "
147+
"Use 'auto', 'waitress', or 'cheroot'."
148+
)
149+
139150
from wsgidav.wsgidav_app import WsgiDAVApp
140151
from services.webdav_provider import InternxtDAVProvider
141152
# Import for SSL
142153
from services.network_utils import NetworkUtils
143-
154+
144155
# Get configuration
145156
webdav_config = config_service.read_webdav_config()
146157

0 commit comments

Comments
 (0)