diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 21966521..7586b4db 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -23,7 +23,7 @@ jobs: run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Install dependencies - run: uv sync --locked --dev + run: uv sync --locked - name: Run Ruff Linter id: ruff-lint diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 9ef0f12f..94cff17f 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -53,7 +53,7 @@ jobs: run: | echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Install dependencies - run: uv sync --locked --dev --extra all + run: uv sync --locked - name: Run tests and check coverage run: uv run pytest --cov=a2a --cov-report term --cov-fail-under=88 - name: Show coverage summary in log diff --git a/pyproject.toml b/pyproject.toml index 1935ed72..496d5d51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,6 @@ style = "pep440" dev = [ "datamodel-code-generator>=0.30.0", "mypy>=1.15.0", - "PyJWT>=2.0.0", "pytest>=8.3.5", "pytest-asyncio>=0.26.0", "pytest-cov>=6.1.1", @@ -101,14 +100,12 @@ dev = [ "types-protobuf", "types-requests", "pre-commit", - "fastapi>=0.115.2", - "sse-starlette", - "starlette", "pyupgrade", "autoflake", "no_implicit_optional", "trio", "uvicorn>=0.35.0", + "a2a-sdk[all]", ] [[tool.uv.index]] @@ -117,6 +114,9 @@ url = "https://test.pypi.org/simple/" publish-url = "https://test.pypi.org/legacy/" explicit = true +[tool.uv.sources] +a2a-sdk = { workspace = true } + [tool.mypy] plugins = ["pydantic.mypy"] exclude = ["src/a2a/grpc/"] diff --git a/scripts/run_integration_tests.sh b/scripts/run_db_tests.sh similarity index 98% rename from scripts/run_integration_tests.sh rename to scripts/run_db_tests.sh index 5b976713..fd2814ce 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_db_tests.sh @@ -96,7 +96,7 @@ trap cleanup EXIT echo "Running integration tests..." cd "$PROJECT_ROOT" -uv run --extra all pytest -v \ +uv run pytest -v \ tests/server/tasks/test_database_task_store.py \ tests/server/tasks/test_database_push_notification_config_store.py \ "${PYTEST_ARGS[@]}" diff --git a/tests/README.md b/tests/README.md index 872ac723..6c70551c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,10 +1,58 @@ ## Running the tests -1. Run the tests +1. Run all tests (excluding those requiring real DBs, see item 3): ```bash - uv run pytest -v -s client/test_client_factory.py + uv run pytest ``` + ``` + + **Useful Flags:** + - `-v` (verbose): Shows more detailed output, including each test name as it runs. + - `-s` (no capture): Allows stdout (print statements) to show in the console. Useful for debugging. + + Example with flags: + ```bash + uv run pytest -v -s + ``` + + Note: Some tests require external databases (PostgreSQL, MySQL) and will be skipped if the corresponding environment variables (`POSTGRES_TEST_DSN`, `MYSQL_TEST_DSN`) are not set. + +2. Run specific tests: + ```bash + # Run a specific test file + uv run pytest tests/client/test_client_factory.py + + # Run a specific test function + uv run pytest tests/client/test_client_factory.py::test_client_factory_connect_with_url + + # Run tests in a specific folder + uv run pytest tests/client/ + ``` + +3. Run database integration tests (requires Docker): + ```bash + ./scripts/run_db_tests.sh + ``` + + This script will: + - Start PostgreSQL and MySQL containers using Docker Compose. + - Run the database integration tests. + - Stop the containers after tests finish. + + You can also run tests for a specific database: + ```bash + ./scripts/run_db_tests.sh --postgres + # or + ./scripts/run_db_tests.sh --mysql + ``` + + To keep the databases running for debugging: + ```bash + ./scripts/run_db_tests.sh --debug + ``` + (Follow the onscreen instructions to export DSNs and run pytest manually). + In case of failures, you can clean up the cache: 1. `uv clean` diff --git a/uv.lock b/uv.lock index 287d87e6..58ccefe4 100644 --- a/uv.lock +++ b/uv.lock @@ -66,13 +66,12 @@ telemetry = [ [package.dev-dependencies] dev = [ + { name = "a2a-sdk", extra = ["all"] }, { name = "autoflake" }, { name = "datamodel-code-generator" }, - { name = "fastapi" }, { name = "mypy" }, { name = "no-implicit-optional" }, { name = "pre-commit" }, - { name = "pyjwt" }, { name = "pytest" }, { name = "pytest-asyncio" }, { name = "pytest-cov" }, @@ -81,8 +80,6 @@ dev = [ { name = "pyupgrade" }, { name = "respx" }, { name = "ruff" }, - { name = "sse-starlette" }, - { name = "starlette" }, { name = "trio" }, { name = "types-protobuf" }, { name = "types-requests" }, @@ -131,13 +128,12 @@ provides-extras = ["all", "encryption", "grpc", "http-server", "mysql", "postgre [package.metadata.requires-dev] dev = [ + { name = "a2a-sdk", extras = ["all"], editable = "." }, { name = "autoflake" }, { name = "datamodel-code-generator", specifier = ">=0.30.0" }, - { name = "fastapi", specifier = ">=0.115.2" }, { name = "mypy", specifier = ">=1.15.0" }, { name = "no-implicit-optional" }, { name = "pre-commit" }, - { name = "pyjwt", specifier = ">=2.0.0" }, { name = "pytest", specifier = ">=8.3.5" }, { name = "pytest-asyncio", specifier = ">=0.26.0" }, { name = "pytest-cov", specifier = ">=6.1.1" }, @@ -146,8 +142,6 @@ dev = [ { name = "pyupgrade" }, { name = "respx", specifier = ">=0.20.2" }, { name = "ruff", specifier = ">=0.12.8" }, - { name = "sse-starlette" }, - { name = "starlette" }, { name = "trio" }, { name = "types-protobuf" }, { name = "types-requests" },