Skip to content

[test]: edit permit#8283

Open
rijulpoudel wants to merge 6 commits into
mainfrom
issue-8270
Open

[test]: edit permit#8283
rijulpoudel wants to merge 6 commits into
mainfrom
issue-8270

Conversation

@rijulpoudel

@rijulpoudel rijulpoudel commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Fixes #8270

Summary by CodeRabbit

  • Bug Fixes
    • Improved permit editing to ensure version changes are tracked correctly.
    • Added/confirmed stale-update detection to prevent conflicting edits using an outdated version.
    • Confirmed permits with no blocking relationships can be deleted successfully.
  • Tests
    • Added coverage for permit deletion without blockers and for permit edits, including stale-object scenarios and version increment behavior.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 91ead4bd-5541-4bb4-898e-69e1bf8cb884

📥 Commits

Reviewing files that changed from the base of the PR and between 393ede0 and 5897a3a.

📒 Files selected for processing (1)
  • specifyweb/backend/businessrules/tests/test_permit.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • specifyweb/backend/businessrules/tests/test_permit.py

📝 Walkthrough

Walkthrough

Permit business-rule tests now cover deleting an unblocked permit and editing permit remarks through API CRUD helpers, including version increments and stale-object detection.

Changes

Permit test coverage

Layer / File(s) Summary
Permit CRUD and version validation
specifyweb/backend/businessrules/tests/test_permit.py
Adds coverage for unblocked permit deletion, persisted remark updates, version increments, and StaleObjectException on outdated versions.

Suggested reviewers: carolinedenis

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Adds an unrelated delete-permit test alongside the requested edit-permit locking test. Move the delete-permit coverage to a separate PR or link it to an issue that requires it.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and directly matches the main change: adding an edit-permit test.
Linked Issues check ✅ Passed The new optimistic-locking edit-permit test satisfies issue #8270's requested coverage.
Automatic Tests ✅ Passed Yes—this PR adds automated unit tests in test_permit.py for deleting a permit and editing it with version/stale-object checks.
Testing Instructions ✅ Passed The new permit tests are explicit and targeted: delete-without-blockers, API edit, version bump, and stale-locking are all covered.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8270

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Warning

One or more dependencies are approaching or past End-of-Life.
Please plan upgrades accordingly.

STATUS=WARNING
NODE_VERSION=20
NODE_CYCLE=20
EOL_DATE=2026-04-30
DAYS_REMAINING=-77

--- Node.js ---
Version: 20
EOL: 2026-04-30
Status: WARNING

STATUS=OK
PYTHON_VERSION=3.12
PYTHON_CYCLE=3.12
EOL_DATE=2028-10-31
DAYS_REMAINING=838

--- Python ---
Version: 3.12
EOL: 2028-10-31
Status: OK

STATUS=WARNING
DJANGO_VERSION=4.2
DJANGO_CYCLE=4.2
EOL_DATE=2026-04-07
DAYS_REMAINING=-100

--- Django ---
Version: 4.2
EOL: 2026-04-07
Status: WARNING


@rijulpoudel rijulpoudel changed the title Issue 8270 [test]: edit permit Jul 8, 2026
Base automatically changed from issue-8269 to issue-8268 July 10, 2026 06:49
Base automatically changed from issue-8268 to main July 14, 2026 08:44
@rijulpoudel

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit Full Review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 44 minutes.

@CarolineDenis

Copy link
Copy Markdown
Contributor

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
specifyweb/backend/businessrules/tests/test_permit.py (1)

158-159: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use a def statement instead of assigning a lambda to a variable.

Assigning a lambda expression to a variable violates PEP 8. Please define a local function using def instead to adhere to standard Python style guidelines.

♻️ Proposed refactor
-        skip_perms_check = lambda x: None `#skip` the permissions checks
-        data = get_resource('permit', permit.id, skip_perms_check) # fetches the permit from the database and stores in the data dictionary
+        def skip_perms_check(x):
+            return None `#skip` the permissions checks
+        data = get_resource('permit', permit.id, skip_perms_check) # fetches the permit from the database and stores in the data dictionary
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@specifyweb/backend/businessrules/tests/test_permit.py` around lines 158 -
159, Replace the skip_perms_check lambda assignment with a locally defined
function named skip_perms_check, preserving its current behavior of accepting
one argument and returning None; continue passing it to get_resource unchanged.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@specifyweb/backend/businessrules/tests/test_permit.py`:
- Around line 158-159: Replace the skip_perms_check lambda assignment with a
locally defined function named skip_perms_check, preserving its current behavior
of accepting one argument and returning None; continue passing it to
get_resource unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: da0b2bd0-3c16-4f3e-8e28-e122af1e63ce

📥 Commits

Reviewing files that changed from the base of the PR and between 2deb51a and 393ede0.

📒 Files selected for processing (1)
  • specifyweb/backend/businessrules/tests/test_permit.py

@rijulpoudel rijulpoudel added this to the 7.12.1 milestone Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

[test]: Add unit test for editing a permit (version/optimistic locking)

2 participants