Skip to content

Commit fd0ffbf

Browse files
committed
tests: improve local dev experience
1 parent dc1fedd commit fd0ffbf

5 files changed

Lines changed: 55 additions & 16 deletions

File tree

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
run: |
5454
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
5555
- name: Install dependencies
56-
run: uv sync --locked --dev --extra all
56+
run: uv sync --locked --dev
5757
- name: Run tests and check coverage
5858
run: uv run pytest --cov=a2a --cov-report term --cov-fail-under=88
5959
- name: Show coverage summary in log

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ style = "pep440"
8989
dev = [
9090
"datamodel-code-generator>=0.30.0",
9191
"mypy>=1.15.0",
92-
"PyJWT>=2.0.0",
9392
"pytest>=8.3.5",
9493
"pytest-asyncio>=0.26.0",
9594
"pytest-cov>=6.1.1",
@@ -101,14 +100,12 @@ dev = [
101100
"types-protobuf",
102101
"types-requests",
103102
"pre-commit",
104-
"fastapi>=0.115.2",
105-
"sse-starlette",
106-
"starlette",
107103
"pyupgrade",
108104
"autoflake",
109105
"no_implicit_optional",
110106
"trio",
111107
"uvicorn>=0.35.0",
108+
"a2a-sdk[all]",
112109
]
113110

114111
[[tool.uv.index]]
@@ -117,6 +114,9 @@ url = "https://test.pypi.org/simple/"
117114
publish-url = "https://test.pypi.org/legacy/"
118115
explicit = true
119116

117+
[tool.uv.sources]
118+
a2a-sdk = { workspace = true }
119+
120120
[tool.mypy]
121121
plugins = ["pydantic.mypy"]
122122
exclude = ["src/a2a/grpc/"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ trap cleanup EXIT
9696
echo "Running integration tests..."
9797
cd "$PROJECT_ROOT"
9898

99-
uv run --extra all pytest -v \
99+
uv run pytest -v \
100100
tests/server/tasks/test_database_task_store.py \
101101
tests/server/tasks/test_database_push_notification_config_store.py \
102102
"${PYTEST_ARGS[@]}"

tests/README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,55 @@
11
## Running the tests
22

3-
1. Run the tests
3+
1. Run all tests (including those requiring optional dependencies like grpc):
44
```bash
5-
uv run pytest -v -s client/test_client_factory.py
5+
uv run pytest
66
```
77

8+
```
9+
10+
**Useful Flags:**
11+
- `-v` (verbose): Shows more detailed output, including each test name as it runs.
12+
- `-s` (no capture): Allows stdout (print statements) to show in the console. Useful for debugging.
13+
14+
Example with flags:
15+
```bash
16+
uv run pytest -v -s
17+
```
18+
19+
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.
20+
21+
2. Run specific tests:
22+
```bash
23+
# Run a specific test file
24+
uv run pytest tests/client/test_client_factory.py
25+
26+
# Run a specific test function
27+
uv run pytest tests/client/test_client_factory.py::test_create_client
28+
```
29+
30+
3. Run database integration tests (requires Docker):
31+
```bash
32+
./scripts/run_db_tests.sh
33+
```
34+
35+
This script will:
36+
- Start PostgreSQL and MySQL containers using Docker Compose.
37+
- Run the database integration tests.
38+
- Stop the containers after tests finish.
39+
40+
You can also run tests for a specific database:
41+
```bash
42+
./scripts/run_db_tests.sh --postgres
43+
# or
44+
./scripts/run_db_tests.sh --mysql
45+
```
46+
47+
To keep the databases running for debugging:
48+
```bash
49+
./scripts/run_db_tests.sh --debug
50+
```
51+
(Follow the onscreen instructions to export DSNs and run pytest manually).
52+
853
In case of failures, you can clean up the cache:
954

1055
1. `uv clean`

uv.lock

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)