fix: remove redundant CI when clause + use side_effect in pagination test #14

Merged
forgejo_admin merged 1 commit from 13-epilogue-nits-ci-when-test-style into main 2026-03-14 19:20:22 +00:00
Contributor

Summary

Remove redundant step-level when filter from CI test step and switch pagination test mock from return_value to side_effect for stricter enforcement and consistency.

Changes

  • .woodpecker.yml -- Removed the step-level when: event: [push, pull_request] on the test step. The pipeline-level when (line 2-3) already restricts all steps to these events, making the step-level filter redundant.
  • tests/test_set_label_pagination.py -- Changed test_single_page_no_extra_calls to use side_effect=[labels] instead of return_value=labels. This is semantically superior: side_effect with a list raises StopIteration if the mock is called more times than expected, enforcing the single-call assertion. Also consistent with the other three tests in the same class.

Test Plan

  • pytest tests/ -v -- all 4 unit tests pass, 8 integration tests skip (expected without creds)
  • ruff check and ruff format --check both pass
  • CI pipeline should pass

Review Checklist

  • Redundant when clause removed from test step in .woodpecker.yml
  • Mock style changed to side_effect for semantic correctness
  • All tests pass after changes
  • Ruff lint and format checks pass
  • limit=100 nit reviewed -- integration tests only, not actionable (skipped per issue guidance)
  • Plan: plan-pal-e-agency (traceability)
  • Closes #13
## Summary Remove redundant step-level `when` filter from CI test step and switch pagination test mock from `return_value` to `side_effect` for stricter enforcement and consistency. ## Changes - **`.woodpecker.yml`** -- Removed the step-level `when: event: [push, pull_request]` on the test step. The pipeline-level `when` (line 2-3) already restricts all steps to these events, making the step-level filter redundant. - **`tests/test_set_label_pagination.py`** -- Changed `test_single_page_no_extra_calls` to use `side_effect=[labels]` instead of `return_value=labels`. This is semantically superior: `side_effect` with a list raises `StopIteration` if the mock is called more times than expected, enforcing the single-call assertion. Also consistent with the other three tests in the same class. ## Test Plan - `pytest tests/ -v` -- all 4 unit tests pass, 8 integration tests skip (expected without creds) - `ruff check` and `ruff format --check` both pass - CI pipeline should pass ## Review Checklist - [x] Redundant `when` clause removed from test step in .woodpecker.yml - [x] Mock style changed to `side_effect` for semantic correctness - [x] All tests pass after changes - [x] Ruff lint and format checks pass - [x] `limit=100` nit reviewed -- integration tests only, not actionable (skipped per issue guidance) ## Related - Plan: `plan-pal-e-agency` (traceability) - Closes #13
fix: remove redundant CI when clause + use side_effect in pagination test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
281f49b918
Remove the step-level `when` filter on the test step in .woodpecker.yml
since the pipeline-level `when` already restricts to push/pull_request.

Change `return_value` to `side_effect` in test_single_page_no_extra_calls
for consistency with other pagination tests and stricter call-count
enforcement (side_effect raises StopIteration on unexpected extra calls).

Closes #13

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Contributor

Self-Review: PASS

Diff reviewed: 2 files, +2/-4 lines.

  1. .woodpecker.yml -- Redundant step-level when removed. Pipeline-level when still governs. Publish step retains its own when (branch filter), which is distinct and necessary. Correct.
  2. tests/test_set_label_pagination.py -- return_value changed to side_effect=[labels]. Wrapping in a list is correct: first call returns the full labels list, extra calls raise StopIteration. Consistent with other pagination tests in the class.

Tests: 4/4 unit tests pass. 8 integration tests skip (expected). Ruff clean.

No findings. Ready for merge review.

## Self-Review: PASS **Diff reviewed**: 2 files, +2/-4 lines. 1. `.woodpecker.yml` -- Redundant step-level `when` removed. Pipeline-level `when` still governs. Publish step retains its own `when` (branch filter), which is distinct and necessary. Correct. 2. `tests/test_set_label_pagination.py` -- `return_value` changed to `side_effect=[labels]`. Wrapping in a list is correct: first call returns the full labels list, extra calls raise `StopIteration`. Consistent with other pagination tests in the class. **Tests**: 4/4 unit tests pass. 8 integration tests skip (expected). Ruff clean. No findings. Ready for merge review.
Author
Contributor

PR #14 Review

BLOCKERS

None.

NITS

  1. test_empty_repo_labels still uses return_value (line 101 of test_set_label_pagination.py). The PR description says the change makes test_single_page_no_extra_calls "consistent with the other three tests in the same class," but test_empty_repo_labels still uses return_value = [] rather than side_effect. This is defensible (the empty list triggers the if not batch: break path on the first call, so side_effect adds no enforcement value there), but the consistency claim in the PR description is slightly overstated. Non-blocking -- the existing code is correct.

SOP COMPLIANCE

  • Branch named after issue (13-epilogue-nits-ci-when-test-style references issue #13)
  • PR body follows template (Summary, Changes, Test Plan, Related)
  • Related references plan slug (plan-pal-e-agency)
  • Closes #13 present in PR body
  • No secrets or credentials committed
  • No scope creep (2 files, -4/+2 lines, exactly matching issue scope)

Code Review Notes

  • .woodpecker.yml: The pipeline-level when (line 2-3) already restricts all steps to [push, pull_request]. The removed step-level when was genuinely redundant. The publish step's when (push + main) is correctly preserved since it adds branch filtering.
  • test_set_label_pagination.py: side_effect=[labels] is semantically correct. It exhausts the list after one call, so a second call to issue_list_labels would raise StopIteration -- stricter enforcement of the "single call" assertion on line 72. The comment update is accurate.

VERDICT: APPROVED

## PR #14 Review ### BLOCKERS None. ### NITS 1. **`test_empty_repo_labels` still uses `return_value`** (line 101 of `test_set_label_pagination.py`). The PR description says the change makes `test_single_page_no_extra_calls` "consistent with the other three tests in the same class," but `test_empty_repo_labels` still uses `return_value = []` rather than `side_effect`. This is defensible (the empty list triggers the `if not batch: break` path on the first call, so `side_effect` adds no enforcement value there), but the consistency claim in the PR description is slightly overstated. Non-blocking -- the existing code is correct. ### SOP COMPLIANCE - [x] Branch named after issue (`13-epilogue-nits-ci-when-test-style` references issue #13) - [x] PR body follows template (Summary, Changes, Test Plan, Related) - [x] Related references plan slug (`plan-pal-e-agency`) - [x] `Closes #13` present in PR body - [x] No secrets or credentials committed - [x] No scope creep (2 files, -4/+2 lines, exactly matching issue scope) ### Code Review Notes - **`.woodpecker.yml`**: The pipeline-level `when` (line 2-3) already restricts all steps to `[push, pull_request]`. The removed step-level `when` was genuinely redundant. The publish step's `when` (push + main) is correctly preserved since it adds branch filtering. - **`test_set_label_pagination.py`**: `side_effect=[labels]` is semantically correct. It exhausts the list after one call, so a second call to `issue_list_labels` would raise `StopIteration` -- stricter enforcement of the "single call" assertion on line 72. The comment update is accurate. ### VERDICT: APPROVED
forgejo_admin deleted branch 13-epilogue-nits-ci-when-test-style 2026-03-14 19:20:22 +00:00
Sign in to join this conversation.
No description provided.