From 7d21249e84bda642e06f0a145d7bd77abf90ba66 Mon Sep 17 00:00:00 2001 From: glados Date: Tue, 14 Jan 2025 13:14:16 +0100 Subject: [PATCH] Update --- .github/workflows/test_package.yml | 2 +- tests/conftest.py | 9 +++++++++ smoke_test.py => tests/test_basic.py | 11 +---------- tests/{ipybox_test.py => test_ipybox.py} | 7 ------- 4 files changed, 11 insertions(+), 18 deletions(-) create mode 100644 tests/conftest.py rename smoke_test.py => tests/test_basic.py (69%) rename tests/{ipybox_test.py => test_ipybox.py} (97%) diff --git a/.github/workflows/test_package.yml b/.github/workflows/test_package.yml index 39a6f85..b2d82c5 100644 --- a/.github/workflows/test_package.yml +++ b/.github/workflows/test_package.yml @@ -104,5 +104,5 @@ jobs: run: | pip install dist/*.whl pip install pytest pytest-asyncio - pytest smoke_test.py + pytest tests/test_basic.py pip uninstall -y ipybox diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..879531a --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,9 @@ +import tempfile + +import pytest + + +@pytest.fixture(scope="module") +async def workspace(): + with tempfile.TemporaryDirectory() as temp_dir: + yield temp_dir diff --git a/smoke_test.py b/tests/test_basic.py similarity index 69% rename from smoke_test.py rename to tests/test_basic.py index a8b845e..71afedb 100644 --- a/smoke_test.py +++ b/tests/test_basic.py @@ -1,28 +1,19 @@ -import tempfile - import pytest from ipybox import ExecutionClient, ExecutionContainer -@pytest.fixture(scope="module") -async def workspace(): - with tempfile.TemporaryDirectory() as temp_dir: - yield temp_dir - - @pytest.fixture(scope="module") async def executor(workspace: str): async with ExecutionContainer( tag="ghcr.io/gradion-ai/ipybox:minimal", binds={workspace: "workspace"}, - env={"TEST_VAR": "test_val"}, ) as container: async with ExecutionClient(host="localhost", port=container.port) as client: yield client @pytest.mark.asyncio(loop_scope="module") -async def test_single_command_output(executor): +async def test_basic_functionality(executor): result = await executor.execute("print('Hello, world!')") assert result.text == "Hello, world!" diff --git a/tests/ipybox_test.py b/tests/test_ipybox.py similarity index 97% rename from tests/ipybox_test.py rename to tests/test_ipybox.py index 3485739..3791931 100644 --- a/tests/ipybox_test.py +++ b/tests/test_ipybox.py @@ -1,7 +1,6 @@ import asyncio import re import subprocess -import tempfile from pathlib import Path from typing import Generator @@ -12,12 +11,6 @@ from ipybox import DEFAULT_TAG, ExecutionClient, ExecutionContainer, ExecutionError -@pytest.fixture(scope="module") -async def workspace(): - with tempfile.TemporaryDirectory() as temp_dir: - yield temp_dir - - @pytest.fixture( scope="module", params=["test-root", "test"],