This commit is contained in:
2026-11-12 16:08:41 -05:00
parent 002947e69e
commit 00a768b371
3 changed files with 18 additions and 17 deletions

View File

@@ -2,6 +2,9 @@
- Use full variable names in the new tests. - Use full variable names in the new tests.
- Review all tests in the test files edited or created; refactor the tests using dry-principle.md. - Review all tests in the test files edited or created; refactor the tests using dry-principle.md.
- PRINCIPLE - another experiment: write as many good tests as I could have it do. Not just good tests - as many as it can. (this way you justify so many tests for just the searches concern) - PRINCIPLE - another experiment: write as many good tests as I could have it do. Not just good tests - as many as it can. (this way you justify so many tests for just the searches concern)
- Step3 had to correct it's way of generating a heading "Form exposure" to "Accepted search types versus implemented search types" - speak more simply is my goal. **Form Exposure** was correct and erudite. But it wasn't clear communication.
I love the submission checklist - saved my *ss again.
suggestions - in sandbox, paste text is available, need a copy text too - I generated a coverage report and had to snap shot it to capture it. Copy would be better.
=== ===

View File

@@ -13,7 +13,7 @@ Start at the NearBeach repository root, create a virtual environment and install
```bash ```bash
python3 -m venv .venv python3 -m venv .venv
source .venv/bin/activate source .venv/bin/activate
python3 -m pip install -r requirements.txt python3 -m pip install -r requirements-dev.txt
python3 -m pip install coverage python3 -m pip install coverage
``` ```

View File

@@ -77,31 +77,31 @@ REWROTE
- For each search path that supports closed or include_closed filtering, create open and closed records the user can access. Check the default behavior and each supported toggle value. Add a closed record the user cannot access, to prove that turning on the toggle doesn't skirt around visibility rules. If an endpoint is missing either feature, note that gap. Do not add the feature. Run the new tests and the full search suite. Then report the results and any open questions about the contract. - For each search path that supports closed or include_closed filtering, create open and closed records the user can access. Check the default behavior and each supported toggle value. Add a closed record the user cannot access, to prove that turning on the toggle doesn't skirt around visibility rules. If an endpoint is missing either feature, note that gap. Do not add the feature. Run the new tests and the full search suite. Then report the results and any open questions about the contract.
### Step 3A - Cover Main Search Text and Numeric Matching 7 ### Step 3A - Cover Main Search Text and Numeric Matching
**Implementation prompt:** **Implementation prompt:**
- Add focused main-search tests for the matching branches in SearchObjects. Verify exact and partial title matches, case-insensitive matching, and multi-term AND logic. Include a full match, a first-term-only match, a second-term-only match, and an unrelated record so replacing AND with OR would fail the test. Verify empty and no-match queries against the validated form behaviour. - Add focused main-search tests for the matching branches in SearchObjects. Verify exact and partial title matches, case-insensitive matching, and multi-term AND logic. Include a full match, a first-term-only match, a second-term-only match, and an unrelated record so replacing AND with OR would fail the test. Verify empty and no-match queries against the validated form behaviour.
- Cover numeric tokens with deliberately controlled data: one record matching by primary key but not title, another matching a numeric substring in its title but having a different primary key, and an unrelated record. Both legitimate matches should be returned. Add a mixed text/numeric query to prove that the numeric ID-or-title condition still combines with the other token using AND. Cover the RFC's rfc_id mapping and the requirement item's own ID, not just the default task mapping. - Cover numeric tokens with intentionally controlled data: one record matching by primary key but not title, another matching a numeric substring in its title but having a different primary key, and an unrelated record. Both legitimate matches should be returned. Add a mixed text/numeric query to prove that the numeric ID-or-title condition still combines with the other token using AND. Cover the RFC's rfc_id mapping and the requirement item's own ID, not just the default task mapping.
- Keep datasets below the page limit unless pagination is the subject of the test. Do not assume unsupported tokenisation, fuzzy matching, exact-only numeric matching, or stable ordering. Run the focused tests and search suite. If the existing behaviour conflicts with the intended contract, explain the discrepancy before modifying production code or accepting it as correct. - Keep datasets below the page limit unless pagination is the subject of the test. Do not assume unsupported tokenization, fuzzy matching, exact-only numeric matching, or stable ordering. Run the focused tests and search suite. If the existing behaviour conflicts with the specified contract, explain the problems before modifying production code or accepting it as correct.
REWROTE
### Step 3B - Cover Main Search Visibility and Soft Deletion
8 ### Step 3B - Cover Main Search Visibility and Soft Deletion
**Implementation prompt:** **Implementation prompt:**
- Add main-search-specific visibility tests using real users, groups, memberships, and ObjectAssignment rows. Verify that an ordinary user cannot bypass group visibility by sending include_all_groups. For a superuser, separately exercise the default group-limited behaviour and the explicit include_all_groups opt-in: the current helper bypasses group limits only when both conditions hold. Do not assume superusers always see every object. - Add main-search-specific visibility tests using real users, groups, memberships, and ObjectAssignment rows. Verify that an ordinary user can't get around group visibility by sending include_all_groups. For a superuser, separately work the default group-limited behaviour and the explicit include_all_groups opt-in: the current helper bypasses group limits only when both conditions hold. Don't assume superusers always see every object.
- Verify that soft-deleted objects remain absent even when include_closed or the superuser all-groups option is enabled. Isolate deleted ObjectAssignment and deleted UserGroup cases: give each test record only the relationship under examination so another active relationship cannot accidentally grant access. Assert both visible and excluded identities and the resulting page metadata. - Verify that soft-deleted objects remain absent even when include_closed or the superuser all-groups option is enabled. Isolate deleted ObjectAssignment and deleted UserGroup cases: Avoid accidentally granting access by giving each test record only the relationship under examination. Assert both visible and excluded identities and the resulting page metadata.
- Add requirement-item tests proving that access follows the parent requirement's assignment, while returned and numerically searched IDs belong to the requirement item itself. Give the parent and child deliberately different IDs so using the wrong key is detectable. Include an inaccessible parent's item and an item with overlapping authorised group assignments. Coordinate with the later general permission step to avoid duplicating these cases. Run the focused tests and search suite without changing production visibility rules.
### Step 3C - Cover Exclusion of Already-Linked Main Search Results - Add requirement-item tests proving that access follows the parent requirement's assignment, while returned and numerically searched IDs belong to the requirement item itself. Intentionally give the parent and child different IDs so using the wrong key is detectable. Include an inaccessible parent's item and an item with overlapping authorised group assignments. Check with the later general permission step so these cases are not repeated. Run the focused tests and search suite without changing production visibility rules.
9 ### Step 3C - Cover Exclusion of Already-Linked Main Search Results
**Implementation prompt:** **Implementation prompt:**
@@ -112,20 +112,18 @@ REWROTE
- Run the focused tests and search suite. Explain any genuine defect exposed by these cases and ask before changing production code. The objective is to cover the existing linking workflow, not create a new exclusion API. - Run the focused tests and search suite. Explain any genuine defect exposed by these cases and ask before changing production code. The objective is to cover the existing linking workflow, not create a new exclusion API.
### Step 7 - Check Test Sensitivity and Close Coverage Gaps 10 ### Step 7 - Check Test Sensitivity and Close Coverage Gaps
**Implementation prompt:** **Implementation prompt:**
- Review the new suite against the brief's coverage matrix: exact/partial matching, case handling, multi-term AND logic, empty/no-match results, pagination, permissions, closed-state filtering, counts, and all nine search categories. Include the expanded main-search checks for six configured object types, numeric ID/title matching, selected-type isolation, parent-based requirement-item access, soft deletion, the all-groups opt-in, and exclusion of already-linked objects. Treat at least 20 additional test methods as a floor, not a cap or a reason to split repetitive assertions into artificial tests. Identify missing cases using both that matrix and a fresh coverage report. Run coverage with NearBeach.views.search_views and NearBeach.views.search as the source modules, and report uncovered lines for both target files. - Review the new suite against the brief's coverage checklist: exact/partial matching, case handling, multi-term AND logic, empty/no-match results, pagination, permissions, closed-state filtering, counts, and all nine search categories. Include the expanded main-search checks for six configured object types, numeric ID/title matching, selected-type isolation, parent-based requirement-item access, soft deletion, the all-groups opt-in, and exclusion of already-linked objects. Treat at least 20 additional test methods as a floor, not a cap or a reason to split repetitive assertions into artificial tests. Identify missing cases using both that checklist and a fresh coverage report. Run coverage with NearBeach.views.search_views and NearBeach.views.search as the source modules, and report uncovered lines for both target files.
- Add focused tests for meaningful uncovered behaviour until search_views.py and search/search_objects.py each reach at least 80% statement coverage. Do not lower the target, change exclusions, or mock away the filtering being tested. If reaching the target requires scope beyond the agreed task, explain that before expanding the work.
- Check representative tests for sensitivity: temporarily give a result assertion a deliberately wrong expected identity or count and confirm that the focused test fails for that reason, then restore the correct assertion and rerun it. Keep these checks temporary, do not leave failing assertions or modified production logic behind, and report what was actually verified. Review that assertions reject incorrect results rather than merely exercising branches. - Check representative tests for sensitivity: temporarily give a result assertion a deliberately wrong expected identity or count and confirm that the focused test fails for that reason, then restore the correct assertion and rerun it. Keep these checks temporary, do not leave failing assertions or modified production logic behind, and report what was actually verified. Review that assertions reject incorrect results rather than merely exercising branches.
### Step 8 - Run Final Regression Checks and Review the Diff 11 ### Step 8 - Run Final Regression Checks and Review the Diff
**Implementation prompt:** **Implementation prompt:**
- Review the final diff for unnecessary fixture changes, duplicated setup, brittle ordering assumptions, mocks that bypass real search behaviour, and accidental production changes. Confirm that at least 20 new test methods have been added and each of the nine search categories has meaningful result assertions. Remove addressed TODOs only where justified; leave unrelated gaps alone. - Review the final diff for unnecessary fixture changes, duplicated setup, brittle ordering assumptions, mocks that bypass real search behaviour, and accidental production changes. Confirm that each of the nine search categories has meaningful result assertions. Remove addressed TODOs only where justified; leave unrelated gaps alone.
- Run the search suite with verbose output, the agreed coverage command and report, and the complete existing Django suite. Compare the results with the baseline, explicitly separating pre-existing failures and environment blockers from new regressions. Report the commands, actual test counts, individual coverage percentages for both target modules, changed test and fixture files, and any remaining limitations. Do not describe the task as complete unless the agreed acceptance criteria have been checked; surface any unmet criterion plainly. - Run the search suite with verbose output, the agreed coverage command and report, and the complete existing Django suite. Compare the results with the baseline, explicitly separating pre-existing failures and environment blockers from new regressions. Report the commands, actual test counts, individual coverage percentages for both target modules, changed test and fixture files, and any remaining limitations. Do not describe the task as complete unless the agreed acceptance criteria have been checked; surface any unmet criterion plainly.