test(api,daemon,skills): skipif(win32) for Linux-only tests (green CI Windows)

Once the collection-level blockers were fixed, the Windows runner finally ran the
suite and surfaced 7 pre-existing failures — all tests asserting Linux-only
behavior, while the production code already handles non-Linux gracefully:

- api test_secrets: chmod(0o000) can't make a file unreadable to its owner on
  Windows (the 'unreadable -> None' precondition is unreachable)
- daemon test_scheduler_cron: patches fcntl.flock; fcntl is None on Windows
  (scheduler_cron already skips locking on non-Unix)
- skills test_runner: system_status memory/uptime/processes/summary read Linux
  /proc (skill returns a graceful error on Windows; disk test stays, it's portable)

Guard each with @pytest.mark.skipif(sys.platform == 'win32', reason=...). 68
tests pass on Linux, ruff clean, api+daemon audit 100%.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
AIOSAI
2026-06-15 20:45:25 -07:00
co-authored by Claude Opus 4.8
parent d94336d783
commit 8ad4de11eb
3 changed files with 36 additions and 0 deletions
+7
View File
@@ -33,9 +33,12 @@ Tests — api_key.py (get_secret_cmd):
from __future__ import annotations
import json
import sys
from pathlib import Path
from unittest.mock import patch, MagicMock
import pytest
from aipass.api.apps.modules.api_key import handle_command as _hc # noqa: F401 — seedgo test_coverage detection
from aipass.api.apps.handlers.auth.secrets import (
get_secret,
@@ -140,6 +143,10 @@ class TestGetSecret:
assert result is None
mock_logger.warning.assert_called()
@pytest.mark.skipif(
sys.platform == "win32",
reason="chmod(0o000) does not make a file unreadable to its owner on Windows",
)
def test_unreadable_file_returns_none(self, tmp_path: Path) -> None:
"""OSError when reading file returns None."""
provider_dir = tmp_path / "telegram"
@@ -16,6 +16,7 @@
"""Tests for scheduler_cron dispatch paths."""
import subprocess
import sys
from datetime import datetime
from unittest.mock import MagicMock, patch
@@ -443,6 +444,10 @@ class TestMain:
mock_help.assert_called_once()
assert exc_info.value.code == 0
@pytest.mark.skipif(
sys.platform == "win32",
reason="patches fcntl.flock; fcntl is Unix-only (None on Windows). Scheduler skips locking on non-Unix.",
)
def test_lock_acquisition_failure(self, tmp_path):
from aipass.daemon.apps.scheduler_cron import main
@@ -460,6 +465,10 @@ class TestMain:
assert code == 0 # graceful skip when another instance is running
mock_fd.close.assert_called()
@pytest.mark.skipif(
sys.platform == "win32",
reason="patches fcntl.flock; fcntl is Unix-only (None on Windows). Scheduler skips locking on non-Unix.",
)
def test_lock_acquired_runs_locked(self, tmp_path):
from aipass.daemon.apps.scheduler_cron import main
+20
View File
@@ -8,6 +8,10 @@
"""Tests for the skills runner module."""
import sys
import pytest
from aipass.skills.apps.modules.runner import run_skill
@@ -18,21 +22,37 @@ class TestRunSkillHandler:
assert "Disk Usage" in result["output"]
assert result["error"] is None
@pytest.mark.skipif(
sys.platform == "win32",
reason="system_status memory reads Linux /proc/meminfo; unavailable on Windows (skill returns graceful error)",
)
def test_run_system_status_memory(self):
result = run_skill("system_status", action="memory")
assert result["success"] is True
assert "Memory" in result["output"]
@pytest.mark.skipif(
sys.platform == "win32",
reason="system_status uptime reads Linux /proc/uptime; unavailable on Windows (skill returns graceful error)",
)
def test_run_system_status_uptime(self):
result = run_skill("system_status", action="uptime")
assert result["success"] is True
assert "Uptime" in result["output"]
@pytest.mark.skipif(
sys.platform == "win32",
reason="system_status processes reads Linux /proc; unavailable on Windows (skill returns graceful error)",
)
def test_run_system_status_processes(self):
result = run_skill("system_status", action="processes")
assert result["success"] is True
assert "processes" in result["output"].lower()
@pytest.mark.skipif(
sys.platform == "win32",
reason="system_status summary needs Linux /proc memory data; unavailable on Windows",
)
def test_run_system_status_summary(self):
result = run_skill("system_status", action="summary")
assert result["success"] is True