원클릭으로
build-testing
Test coverage for build.py functions. Real infrastructure probes, justified mocks only.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Test coverage for build.py functions. Real infrastructure probes, justified mocks only.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Project architecture and design principles for vm_builds Ansible project. Includes bake vs configure patterns, two-role service model, and deployment lifecycle.
Python code conventions. Functions return errors, .env parsing strips quotes, type hints required.
Proactive validation patterns to catch issues early, prevent debugging blind, and establish testing habits before problems escalate.
Update skills and rules when encountering new issues to prevent recurrence. Includes hard-fail patterns, code custodianship, and mandatory testing requirements.
LXC container provisioning and configuration patterns. Use when creating LXC services, managing container networking, or handling LXC template operations.
Molecule test performance optimization patterns. Template caching, NTP sync, pct_remote overhead, apt cache, selective rebuilds.
| name | build-testing |
| description | Test coverage for build.py functions. Real infrastructure probes, justified mocks only. |
probe_host to test infrastructure health. Probe the REAL hosts.subprocess.run is justified — don't actually run ansible-playbook from pytest.probe_host is ONLY justified in TestMain error-path tests where you need to
isolate a DIFFERENT error (e.g., "missing playbook" needs to get past the probe step).| Function | Test Class | What it tests |
|---|---|---|
load_env | TestLoadEnv | Real Python parsing: quotes, whitespace, comments, edge cases |
validate_env | TestValidateEnv | Real Python validation: required vars, empty values |
resolve_playbook | TestResolvePlaybook | Real filesystem: actual playbooks/ dir, path resolution |
build_command | TestBuildCommand | Real Python list construction: flags, tags, combined |
find_ansible_playbook | TestFindAnsiblePlaybook | Filesystem + shutil.which: venv, system, missing |
probe_host | TestInfrastructureHealth | REAL TCP probes against REAL hosts from test.env |
resolve_proxmox_host | TestInfrastructureHealth | REAL resolution against REAL PRIMARY_HOST |
main | TestMain | Error paths (mock subprocess.run to avoid running ansible) |
pytest tests/test_build.py -v
TestInfrastructureHealth failures mean REAL infrastructure problems:
test_primary_host_reachable FAILED → home is down. Check power/network.test_ai_host_reachable FAILED → ai is down. NO WoL. Manual power-on required.test_mesh2_host_reachable FAILED → mesh2 is down. Try ./scripts/wol.sh mesh2.These are NOT flaky tests. They are the early warning system. If they fail, your infrastructure has a real problem.
Every patch() or monkeypatch call MUST include a comment with TWO parts:
If you cannot write both sentences, the mock is unjustified — remove it and test the real thing.
# JUSTIFIED: prevent pytest from running ansible-playbook (side effect: 5-min
# playbook run). Test validates command construction, not playbook execution.
monkeypatch.setattr("subprocess.run", fake_run)
# JUSTIFIED: test "missing binary" error path (side effect: none, but real
# binary is always present). Test validates the error message, not binary detection.
monkeypatch.setattr(build, "find_ansible_playbook", lambda: None)
# JUSTIFIED in TestMain ONLY: isolate a different error path
# (side effect: TCP probe blocks for 3s per host). Test validates "missing
# playbook" error, not host reachability — that's tested by TestInfrastructureHealth.
monkeypatch.setattr(build, "probe_host", lambda *a, **kw: True)
# NEVER: mocking probe_host to test infrastructure health
monkeypatch.setattr(build, "probe_host", lambda *a, **kw: True)
env = {"PRIMARY_HOST": "10.0.0.1"} # FAKE IP!
assert build.resolve_proxmox_host(env) == "10.0.0.1" # TRIVIALLY OBVIOUS
# NEVER: mocking socket to test probe_host itself
@patch('socket.create_connection')
def test_probe(mock_conn): # TESTS NOTHING REAL
TestResolveProxmoxHost (5 tests) monkeypatched probe_host with fake IPs.
All 5 passed while all 3 WAN hosts (home, ai, mesh2) were offline. The ai
host had been crashed by modprobe -r amdgpu and nobody knew because the
"host probing tests" never actually probed any hosts. Replaced with
TestInfrastructureHealth that probes real hosts from test.env.