Clean up the sandbox errors test through a class fixture - #224
Clean up the sandbox errors test through a class fixture#224devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🧪 Testing GuideWhat this PR addressesThis is a refactor of the
Steps to verifySince this is a test refactor with no production code changes, there's nothing to reproduce as a "bug." Instead, verify the following:
What to verify (expected behavior)
Note Posted by PR Testing Guide · Tag @mendral-app with feedback. |
Interaction FlowsequenceDiagram
participant Test as TestSandboxErrors
participant Fixture as cleanup fixture (autouse, class-scoped)
participant Helper as _create_sandbox()
participant SDK as SandboxInstance
participant Infra as Compute Plane
Note over Fixture: Before tests
Fixture->>Test: Initialize created_sandboxes = []
Note over Test: test_reads_empty_error_history_on_healthy_sandbox
Test->>Helper: _create_sandbox()
Helper->>Helper: Append name to created_sandboxes
Helper->>SDK: SandboxInstance.create(name, image, region, labels)
SDK->>Infra: Provision sandbox
Helper-->>Test: return name
Test->>SDK: SandboxInstance.get(name)
SDK-->>Test: sandbox instance
Test->>Test: assert errors == []
Note over Test: test_listing_does_not_carry_the_error_history
Test->>Helper: _create_sandbox()
Helper->>SDK: SandboxInstance.create(...)
SDK->>Infra: Provision sandbox
Test->>SDK: SandboxInstance.list(limit=1)
SDK-->>Test: page
Test->>Test: assert len(page.data) > 0, no .errors attr
Note over Fixture: After all tests (yield)
Fixture->>Helper: _safe_delete_sandbox(name) for each
Helper->>SDK: SandboxInstance.delete(name)
SDK->>Infra: Tear down sandbox
SummaryThis PR refactors the
Note Posted by PR Sequence Diagram · Tag @mendral-app with feedback. |
There was a problem hiding this comment.
LGTM
Clean refactoring. The mutable class-variable pattern (created_sandboxes: list[str] = []) works correctly here because the fixture resets it via request.cls.created_sandboxes = [] and test methods mutate the same object through self.created_sandboxes.append(...). The riskiest hunk is the listing test (line 65–70): it creates a sandbox then asserts page.data[0].errors == [] on a limit=1 result that may return a different sandbox, but the assertion is valid regardless since the listing projection drops errors for all sandboxes.
Tag @mendral-app with feedback or questions. View session
|
📋 Created Linear issue ENG-5030 — status: In Progress
Auto-created because no Linear reference was found in the PR title, description, or branch name. Note Posted by Linear Issue Enforcer · Tag @mendral-app with feedback. |
Fixes ENG-5030
Summary
Two review findings on the
sandbox.errorsintegration test merged in #223:try/finallyaround a single test), so an interruption leaked a sandbox. Now an autouse class-scopedcleanupfixture deletes everything the class created, liketest_drive_acl.py.test_listing_does_not_carry_the_error_historyassertedlen(page.data) > 0while creating no sandbox of its own, so it depended on pre-existing workspace state. It now creates its own labeled sandbox first.Assertions are unchanged:
errorsis always a list, empty on a healthy sandbox, and empty on a listing (the projection drops the field).Link to Devin session: https://app.devin.ai/sessions/37e2b2b146c04e8daf2812d81fa0e2e4
Requested by: @drappier-charles
Note
Refactors the sandbox errors integration test to use a class-scoped autouse fixture for cleanup (preventing sandbox leaks on test interruption) and makes
test_listing_does_not_carry_the_error_historyself-contained by creating its own sandbox.Written by Mendral for commit 8dcc8a6.