Clean up test seed Block objects with null anchor_ids #123

Closed
opened 2026-03-09 03:27:36 +00:00 by forgejo_admin · 1 comment

Lineage

todo-test-seed-anchor-ids — QA nit from PR #120 (Epilogue item 9a)

Repo

forgejo_admin/pal-e-docs

User Story

As a developer reading tests
I want test seed data to match production invariants
So that tests don't mask bugs by using invalid data shapes

Context

PR #120 established the invariant that all blocks must have non-null anchor_ids. But test seed helpers in tests/test_blocks_api.py and tests/test_compiled_page_api.py still create Block objects with anchor_id=None. This works because SQLite treats NULLs as distinct for unique constraints, but is inconsistent with the application-level guarantee.

File Targets

Files the agent should modify:

  • tests/test_blocks_api.py — update seed helpers to provide anchor_ids
  • tests/test_compiled_page_api.py — update seed helpers to provide anchor_ids
  • Any other test files that create Block objects with null anchor_ids

Files the agent should NOT touch:

  • src/ — no production code changes needed

Acceptance Criteria

  • All test seed Block objects have non-null anchor_ids
  • anchor_ids follow the {block_type}-{position} pattern for non-heading blocks
  • All existing tests still pass
  • rg "anchor_id=None" tests/ returns zero results for Block creation

Test Expectations

  • All existing tests pass: pytest tests/ -v
  • Run command: pytest tests/ -v

Constraints

  • Test-only change — zero production code modifications
  • Match the pattern established in PR #120

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • todo-test-seed-anchor-ids — tracking TODO
  • PR #120 — parent change that established the invariant
### Lineage `todo-test-seed-anchor-ids` — QA nit from PR #120 (Epilogue item 9a) ### Repo `forgejo_admin/pal-e-docs` ### User Story As a developer reading tests I want test seed data to match production invariants So that tests don't mask bugs by using invalid data shapes ### Context PR #120 established the invariant that all blocks must have non-null anchor_ids. But test seed helpers in `tests/test_blocks_api.py` and `tests/test_compiled_page_api.py` still create Block objects with `anchor_id=None`. This works because SQLite treats NULLs as distinct for unique constraints, but is inconsistent with the application-level guarantee. ### File Targets Files the agent should modify: - `tests/test_blocks_api.py` — update seed helpers to provide anchor_ids - `tests/test_compiled_page_api.py` — update seed helpers to provide anchor_ids - Any other test files that create Block objects with null anchor_ids Files the agent should NOT touch: - `src/` — no production code changes needed ### Acceptance Criteria - [ ] All test seed Block objects have non-null anchor_ids - [ ] anchor_ids follow the `{block_type}-{position}` pattern for non-heading blocks - [ ] All existing tests still pass - [ ] `rg "anchor_id=None" tests/` returns zero results for Block creation ### Test Expectations - [ ] All existing tests pass: `pytest tests/ -v` - Run command: `pytest tests/ -v` ### Constraints - Test-only change — zero production code modifications - Match the pattern established in PR #120 ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `todo-test-seed-anchor-ids` — tracking TODO - PR #120 — parent change that established the invariant
Author
Owner

PR #125 Review

BLOCKERS

None.

NITS

None.

SOP COMPLIANCE

  • Branch named after issue (123-test-seed-anchor-ids references issue #123)
  • PR body follows template (Summary, Changes, Test Plan, Review Checklist, Related)
  • Related references traceability note (todo-test-seed-anchor-ids) -- standalone cleanup, no plan slug needed
  • No secrets committed
  • No unnecessary file changes (2 test files, 5 additions / 5 deletions, pure replacements)
  • Commit messages are descriptive
  • No production code touched (changes scoped entirely to tests/)

VERIFICATION

All 5 anchor_id=None replacements follow the {block_type}-{position} convention correctly:

File Helper position block_type anchor_id Correct
test_blocks_api.py _seed_note_with_blocks() 1 paragraph paragraph-1 Yes
test_blocks_api.py _seed_note_with_blocks() 3 paragraph paragraph-3 Yes
test_blocks_api.py _seed_hierarchical_note() 2 paragraph paragraph-2 Yes
test_compiled_page_api.py _seed_note_with_compiled_page() 1 paragraph paragraph-1 Yes
test_compiled_page_api.py _seed_note_with_compiled_page() 3 paragraph paragraph-3 Yes

Post-change grep confirms: rg "anchor_id=None" tests/ returns zero results for Block creation.

VERDICT: APPROVED

## PR #125 Review ### BLOCKERS None. ### NITS None. ### SOP COMPLIANCE - [x] Branch named after issue (`123-test-seed-anchor-ids` references issue #123) - [x] PR body follows template (Summary, Changes, Test Plan, Review Checklist, Related) - [x] Related references traceability note (`todo-test-seed-anchor-ids`) -- standalone cleanup, no plan slug needed - [x] No secrets committed - [x] No unnecessary file changes (2 test files, 5 additions / 5 deletions, pure replacements) - [x] Commit messages are descriptive - [x] No production code touched (changes scoped entirely to `tests/`) ### VERIFICATION All 5 `anchor_id=None` replacements follow the `{block_type}-{position}` convention correctly: | File | Helper | position | block_type | anchor_id | Correct | |------|--------|----------|------------|-----------|---------| | test_blocks_api.py | `_seed_note_with_blocks()` | 1 | paragraph | `paragraph-1` | Yes | | test_blocks_api.py | `_seed_note_with_blocks()` | 3 | paragraph | `paragraph-3` | Yes | | test_blocks_api.py | `_seed_hierarchical_note()` | 2 | paragraph | `paragraph-2` | Yes | | test_compiled_page_api.py | `_seed_note_with_compiled_page()` | 1 | paragraph | `paragraph-1` | Yes | | test_compiled_page_api.py | `_seed_note_with_compiled_page()` | 3 | paragraph | `paragraph-3` | Yes | Post-change grep confirms: `rg "anchor_id=None" tests/` returns zero results for Block creation. ### VERDICT: APPROVED
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo_admin/pal-e-api#123
No description provided.