mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-12 05:36:40 +00:00
- Move emojis after headline text (CONTRIBUTING.md, actions/, design/, tools/, tests/) - Replace em dashes with colons, semicolons, or complete sentences throughout - Add missing emojis to all headlines in exceptions.md, principles.md, services.md, shell.md, setup.md, pull-request.md, commit.md, act.md, docker.md, pr/README.md - Update H1 titles to reflect renamed directories (actions/, design/) - Fix broken relative links in workflow.md after directory moves - Fix full-path link texts in services.md (style.css.md, javascript.js.md) - Fix broken principles.md link to lint.md after testing/ → actions/testing/ move Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.5 KiB
2.5 KiB
Integration Tests 🔗
This page is the SPOT for integration testing requirements, framework, and structure.
Run integration tests with make test-integration.
Framework 🧰
- You MUST use Python
unittestas the test framework. - Tests that verify real runtime component interactions MUST live under
tests/integration/. - Tests that statically analyze Ansible config or task YAML files without exercising runtime boundaries MUST live under
tests/lint/ansible/instead.
When to Write ✍️
- You MUST add or update integration tests for every
*.pyfile you touch when the change affects behavior across module or runtime boundaries. - Write an integration test when the behavior you are verifying depends on two or more components working together at runtime. For example, verify a lookup plugin reading from real
group_varsor a filter interacting with an Ansible variable structure. - Write a lint test under
tests/lint/ansible/when the check only inspects static YAML structure, config keys, or comment annotations without executing any code.
Requirements 📋
- You MUST NOT mock collaborators that are part of the integration boundary being tested. The point is to verify real interaction.
- You MUST NOT write tests that only assert a file contains a string.
- You MUST NOT write tests only for non-executable files such as
.ymlor.j2. Test the behavior that consumes them. - You SHOULD keep each test focused on one integration boundary.
- You SHOULD test realistic inputs that match what Ansible would pass at runtime.
- You MAY use
unittest.mockto stub out external services or filesystem state that is genuinely outside the integration scope.
How to Create 🛠️
- Identify the integration boundary (e.g. lookup plugin +
group_varsvariable loading). - Decide whether the test exercises a real runtime interaction (
tests/integration/) or only inspects static YAML structure (tests/lint/ansible/). - Create the matching test file under the correct directory if it does not exist.
- Subclass
unittest.TestCase. - Use realistic inputs. Build hypotheses about cross-component behavior before writing assertions.
- Run
make test-integration(ormake test-lintfor lint tests) and verify all tests pass.
Running Specific Tests 🏃
Use TEST_PATTERN to scope the test run to a single file or a glob:
# Run a single integration test file
TEST_PATTERN=test_my_module.py make test-integration
# Run all files matching a prefix
TEST_PATTERN=test_applications*.py make test-integration