Skip to content

Commit

Permalink
add basic snapshot testing to python-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
0div committed Dec 14, 2024
1 parent 9f9a36b commit 0d0ccab
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
17 changes: 17 additions & 0 deletions packages/python-sdk/tests/async/sandbox_async/test_snapshot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest
from e2b import AsyncSandbox


@pytest.mark.skip_debug()
async def test_snapshot(template):
sbx = await AsyncSandbox.create(template, timeout=5)
try:
assert await sbx.is_running()

sandbox_id = await sbx.pause()
assert not await sbx.is_running()

await sbx.resume(sandbox_id)
assert await sbx.is_running()
finally:
await sbx.kill()
13 changes: 8 additions & 5 deletions packages/python-sdk/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import pytest
import pytest_asyncio
import os

from logging import warning

from e2b import Sandbox, AsyncSandbox
import pytest
import pytest_asyncio
from e2b import AsyncSandbox, Sandbox


@pytest.fixture()
def template():
return "base"
return "base_01"


@pytest.fixture()
def sandbox(template, debug):
sandbox = Sandbox(template)

try:
sandbox_id = sandbox.pause()
sandbox.resume(sandbox_id)
yield sandbox
finally:
try:
Expand All @@ -33,6 +34,8 @@ async def async_sandbox(template, debug):
sandbox = await AsyncSandbox.create(template)

try:
sandbox_id = await sandbox.pause()
await sandbox.resume(sandbox_id)
yield sandbox
finally:
try:
Expand Down
17 changes: 17 additions & 0 deletions packages/python-sdk/tests/sync/sandbox_sync/test_snapshot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest
from e2b import Sandbox


@pytest.mark.skip_debug()
def test_snapshot(template):
sbx = Sandbox(template, timeout=5)
try:
assert sbx.is_running()

sandbox_id = sbx.pause()
assert not sbx.is_running()

sbx.resume(sandbox_id)
assert sbx.is_running()
finally:
sbx.kill()

0 comments on commit 0d0ccab

Please sign in to comment.