Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 13 additions & 5 deletions sdks/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ pip install -r test_requirements.txt

Then run the tests:

These live tests mutate server state and may leave residual folders or scoped
artifacts behind. Run them only against a local or disposable test server or
tenant, never against production or shared data.

```bash
# Run all tests (requires a running Morphik server)
pytest morphik/tests/ -v
Expand All @@ -180,20 +184,24 @@ pytest morphik/tests/test_async.py -v
# Skip tests if you don't have a running server
SKIP_LIVE_TESTS=1 pytest morphik/tests/ -v

# Specify a custom server URL for tests
MORPHIK_TEST_URL=http://custom-server:8000 pytest morphik/tests/ -v
# Specify a custom disposable test server URI
# Use direct http(s) endpoints inline; source credential-bearing morphik:// URIs
# from a local secret store or uncommitted env file instead of shell history or CI logs
MORPHIK_TEST_URI=http://custom-server:8000 pytest morphik/tests/ -v
```

### Example Usage Script

The SDK comes with an example script that demonstrates basic usage:
The SDK comes with an example script that demonstrates basic usage. It creates
server data and only partially cleans it up, so run it only against a local or
disposable test environment.

```bash
# Run synchronous example
python -m morphik.tests.example_usage
uv run python -m morphik.tests.example_usage

# Run asynchronous example
python -m morphik.tests.example_usage --async
uv run python -m morphik.tests.example_usage --run-async
```

The example script demonstrates:
Expand Down
28 changes: 19 additions & 9 deletions sdks/python/morphik/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,37 @@ This directory contains tests and example code for the Morphik SDK.

## Running Tests

These live tests mutate server state and may leave residual folders or scoped
artifacts behind. Run them only against a local or disposable test server or
tenant, never against production or shared data.

```bash
# Using default localhost:8000 URL
# Using default localhost:8000 server URI
pytest test_sync.py test_async.py -v

# Tests connect to localhost:8000 by default
# No need to specify a URL unless you want to test against a different server
# No need to specify a URI unless you want to test against a different server

# With a custom server URL (optional)
MORPHIK_TEST_URL=http://custom-url:8000 pytest test_sync.py -v
# With a custom disposable test server URI (optional; applies to sync and async tests)
# Use direct http(s) endpoints inline; source credential-bearing morphik:// URIs
# from a local secret store or uncommitted env file instead of shell history or CI logs
MORPHIK_TEST_URI=http://custom-url:8000 pytest test_sync.py test_async.py -v
```

### Example Usage Script

The example script creates server data and only partially cleans it up. Run it
only against the same local or disposable test environment.

```bash
# Run synchronous example
python example_usage.py
# Run synchronous example from this directory
PYTHONPATH=../.. uv run python example_usage.py

# Run asynchronous example
python example_usage.py --async
# Run asynchronous example from this directory
PYTHONPATH=../.. uv run python example_usage.py --run-async
```

## Environment Variables

- `MORPHIK_TEST_URL` - The URL of the Morphik server to use for tests (default: http://localhost:8000)
- `MORPHIK_TEST_URI` - The Morphik server URI to use for tests; accepts direct `http(s)://` endpoints or authenticated `morphik://` URIs (default: http://localhost:8000)
- `SKIP_LIVE_TESTS` - Set to "1" to skip tests that require a running server
4 changes: 2 additions & 2 deletions sdks/python/morphik/tests/example_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
This can be run to verify that the SDK is working correctly.

Usage:
python example_usage.py [--async]
uv run python example_usage.py [--run-async]

Options:
--async Run the example using the async client
--run-async Run the example using the async client
"""

import argparse
Expand Down