Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,33 @@
run: |
just typing

integration_tests:
runs-on: ubuntu-latest
name: Integration Tests
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v5
with:
enable-cache: true
python-version: "3.9"
- name: Install just
run: uv tool install rust-just
- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@master
with:
version: "8.0"
- name: Install dependencies
run: just install
- name: Run tests
run: |
just integration-tests

make_sdist:
runs-on: ubuntu-latest
name: "Make an sdist"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
steps:
- uses: actions/checkout@v5
with:
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ a use the ticket number as the "reason" parameter to the decorator, e.g. `@flaky
When running tests locally (not in CI), the `flaky` decorator will be disabled unless `ENABLE_FLAKY` is set.
To disable the `flaky` decorator in CI, you can use `evergreen patch --param DISABLE_FLAKY=1`.

## Integration Tests

The `integration_tests` directory has a set of scripts that verify the usage of PyMongo with downstream packages or frameworks. See the [README](./integration_tests/README.md) for more information.

To run the tests, use `just integration_tests`.

## Specification Tests

The MongoDB [specifications repository](https://github.com/mongodb/specifications)
Expand Down
19 changes: 19 additions & 0 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Integration Tests

A set of tests that verify the usage of PyMongo with downstream packages or frameworks.

Each test uses [PEP 723 inline metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/) and can be run using `pipx` or `uv`.

The `run.sh` convenience script can be used to run all of the files using `uv`.

When creating a new script, use the following snippet to ensure that the local version of PyMongo is used:


```python
# Use pymongo from parent directory.
import sys
from pathlib import Path

root = Path(__file__).parent.parent
sys.path.insert(0, str(root))
```
17 changes: 17 additions & 0 deletions integration_tests/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Run all of the integration test files using `uv run`.
set -eu

HERE=$(dirname ${BASH_SOURCE:-$0})
pushd "$HERE" > /dev/null
trap 'popd' ERR

for file in test_*.py ; do
echo "-----------------"
echo "Running $file..."
uv run $file
echo "Running $file...done."
echo "-----------------"
done

popd
27 changes: 27 additions & 0 deletions integration_tests/test_uv_loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# /// script
# dependencies = [
# "uvloop>=0.18"
# ]
# requires-python = ">=3.10"
# ///
from __future__ import annotations

import sys
from pathlib import Path

import uvloop

# Use pymongo from parent directory.
root = Path(__file__).parent.parent
sys.path.insert(0, str(root))

from pymongo import AsyncMongoClient # noqa: E402


async def main():
client = AsyncMongoClient()
result = await client.admin.command("ping")
assert result["ok"]


uvloop.run(main())
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ setup-tests *args="":
teardown-tests:
bash .evergreen/scripts/teardown-tests.sh

[group('test')]
integration-tests:
UV_FROZEN="0" bash integration_tests/run.sh

[group('server')]
run-server *args="":
bash .evergreen/scripts/run-server.sh {{args}}
Expand Down
Loading