[test]: add permit attachment add and delete#8281
Conversation
|
Warning One or more dependencies are approaching or past End-of-Life. |
📝 WalkthroughWalkthroughChangesPermit Business Rule Tests
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
[test]: delete permit without blockers
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@specifyweb/backend/businessrules/tests/test_permit.py`:
- Around line 126-131: Update the deletion assertions in the test containing
permit_attachment.delete() so they verify the related Attachment row remains
instead of expecting its count to be zero; retain the permitattachments count
assertion and use the existing attachment identifier to assert the row still
exists.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4350207c-6a12-49c1-9561-25f14d5be342
📒 Files selected for processing (1)
specifyweb/backend/businessrules/tests/test_permit.py
| # Delete the attachment | ||
| permit_attachment.delete() | ||
|
|
||
| # Verifying it's gone | ||
| self.assertEqual(permit.permitattachments.count(), 0) | ||
| self.assertEqual(models.Attachment.objects.filter(id=attachment.id).count(), 0) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check for post_delete signals connected to Permitattachment
rg -n "post_delete" --type=py -C3 specifyweb/specify/models.py | grep -i -A3 -B3 "permitattachment\|Permitattachment"
rg -n "post_delete" --type=py -C3 specifyweb/ | grep -i -A5 -B5 "permitattachment\|PermitAttachment"
# Also check for any custom delete method on Permitattachment
rg -n "class Permitattachment" --type=py -A30 specifyweb/specify/models.py
# Check signal handlers broadly
rg -n "post_delete" --type=py specifyweb/specify/ | head -30Repository: specify/specify7
Length of output: 2073
permit_attachment.delete() should not clear the Attachment row. The final assertion should expect the attachment to remain, unless there’s separate cleanup logic that explicitly deletes it; otherwise this test will fail.
🤖 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 126 -
131, Update the deletion assertions in the test containing
permit_attachment.delete() so they verify the related Attachment row remains
instead of expecting its count to be zero; retain the permitattachments count
assertion and use the existing attachment identifier to assert the row still
exists.
Fixes #8268
Summary by CodeRabbit