Skip to content

Commit 7d4f7b0

Browse files
authored
getInfo: added tests, updated documentation with example return (#638)
Unborked version of #637
2 parents 197d966 + c0efd6f commit 7d4f7b0

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

apps/web/src/app/(docs)/docs/sandbox/page.mdx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@ const sandbox = await Sandbox.create({ timeoutMs: 60_000 })
7070
// Retrieve sandbox information.
7171
const info = await sandbox.getInfo()
7272

73-
// Retrieve sandbox expiration date.
74-
const expirationDate = info.endAt
75-
console.log(expirationDate)
73+
console.log(info)
74+
75+
// {
76+
// "sandboxId": "iiny0783cype8gmoawzmx-ce30bc46",
77+
// "templateId": "rki5dems9wqfm4r03t7g",
78+
// "name": "base",
79+
// "metadata": {},
80+
// "startedAt": "2025-03-24T15:37:58.076Z",
81+
// "endAt": "2025-03-24T15:42:58.076Z"
82+
// }
7683
```
7784

7885
```python
@@ -81,9 +88,18 @@ from e2b_code_interpreter import Sandbox
8188
# Create sandbox with and keep it running for 60 seconds.
8289
sandbox = Sandbox(timeout=60)
8390

84-
# Retrieve sandbox expiration date.
85-
expiration_date = sandbox.get_info().end_at
86-
print(expiration_date)
91+
# Retrieve sandbox information.
92+
info = sandbox.get_info()
93+
94+
print(info)
95+
96+
# SandboxInfo(sandbox_id='ig6f1yt6idvxkxl562scj-419ff533',
97+
# template_id='u7nqkmpn3jjf1tvftlsu',
98+
# name='base',
99+
# metadata={},
100+
# started_at=datetime.datetime(2025, 3, 24, 15, 42, 59, 255612, tzinfo=tzutc()),
101+
# end_at=datetime.datetime(2025, 3, 24, 15, 47, 59, 255612, tzinfo=tzutc())
102+
# )
87103
```
88104
</CodeGroup>
89105

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { expect } from 'vitest'
2+
3+
import { sandboxTest, isDebug } from '../setup.js'
4+
5+
sandboxTest.skipIf(isDebug)('get sandbox info', async ({ sandbox }) => {
6+
const info = await sandbox.getInfo()
7+
expect(info).toBeDefined()
8+
expect(info.sandboxId).toBe(sandbox.sandboxId)
9+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
from e2b import AsyncSandbox
4+
5+
6+
@pytest.mark.skip_debug()
7+
async def test_get_info(async_sandbox: AsyncSandbox):
8+
info = await async_sandbox.get_info()
9+
assert info.sandbox_id == async_sandbox.sandbox_id
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
from e2b import Sandbox
4+
5+
6+
@pytest.mark.skip_debug()
7+
def test_get_info(sandbox: Sandbox):
8+
info = sandbox.get_info()
9+
assert info.sandbox_id == sandbox.sandbox_id

0 commit comments

Comments
 (0)