-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathtest_async_contexts.py
More file actions
47 lines (30 loc) · 1.47 KB
/
test_async_contexts.py
File metadata and controls
47 lines (30 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from e2b_code_interpreter.code_interpreter_async import AsyncSandbox
async def test_create_context_with_no_options(async_sandbox: AsyncSandbox):
context = await async_sandbox.create_code_context()
contexts = await async_sandbox.list_code_contexts()
last_context = contexts[-1]
assert last_context.id is not None
assert last_context.language == context.language
assert last_context.cwd == context.cwd
async def test_create_context_with_options(async_sandbox: AsyncSandbox):
context = await async_sandbox.create_code_context(
language="python",
cwd="/home/user/test",
)
contexts = await async_sandbox.list_code_contexts()
last_context = contexts[-1]
assert last_context.id is not None
assert last_context.language == context.language
assert last_context.cwd == context.cwd
async def test_remove_context(async_sandbox: AsyncSandbox):
context = await async_sandbox.create_code_context()
await async_sandbox.remove_code_context(context.id)
async def test_list_contexts(async_sandbox: AsyncSandbox):
contexts = await async_sandbox.list_code_contexts()
# default contexts should include python and javascript
languages = [context.language for context in contexts]
assert "python" in languages
assert "javascript" in languages
async def test_restart_context(async_sandbox: AsyncSandbox):
context = await async_sandbox.create_code_context()
await async_sandbox.restart_code_context(context.id)