refactor(tests): behavioral tests and shared factories#32
Merged
Conversation
…ts and shared factories Replace 10-deep @patch stacks in TestRunUp with a FakeServiceLayer test double that mocks only at the OS boundary (subprocess, HTTP, signals). Consolidate ~50 duplicate helper functions (_make_entry x9, _make_stack_yaml x5, etc.) into tests/factories.py. Structure all tests with AAA comments. Net result: -577 lines, same 1481 tests passing, tests now assert behavior not mock wiring. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Running `make lint` now executes both ruff and pyright so type errors are caught locally before push, not just in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
weklund
added a commit
that referenced
this pull request
Apr 4, 2026
🤖 I have created a release *beep* *boop* --- ## [0.3.5](v0.3.4...v0.3.5) (2026-04-04) ### Features * expand ruff lint rules with tier 1+2 quality rulesets ([#22](#22)) ([75490f6](75490f6)) ### Refactors * **tests:** replace brittle mock-heavy tests with behavioral tests and shared factories ([#32](#32)) ([9af6078](9af6078)) - `FakeServiceLayer` replaces 10-deep `@patch` stacks in `TestRunUp` - Consolidate ~50 duplicate helpers into `tests/factories.py` - AAA comments (`# Arrange`, `# Act`, `# Assert`) across 17 test files - `make lint` now includes pyright for shift-left type checking - Net: -577 lines, 1,481 tests pass, 73% reduction in `@patch` usage --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Wes Eklund <s.wes35@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestRunUp(13 tests) previously used 10@patchdecorators per test, testing mock wiring rather than real behavior. Now uses aFakeServiceLayertest double that mocks only at the OS boundary (subprocess, HTTP, signals), while real YAML loading, config reading, and pure functions execute for real.tests/factories.py—_make_entry(9 files),_make_stack_yaml(5 files),_make_test_catalog(6 files),_make_profile(5 files), and others now live in one shared module.# Arrange,# Act,# Assert) to all non-trivial tests across 17 modified files.Key new files
tests/factories.pytests/fakes.pyFakeServiceLayer— configurable test double for OS-boundary functionstests/unit/conftest.pyBefore → After (TestRunUp example)
Stats
@patchusages in unit tests (73% reduction)Test plan
uv run pytest tests/unit/ -x -q --tb=short— all 1,481 tests passuv run ruff check tests/— all lint checks pass🤖 Generated with Claude Code