Metadata-Version: 2.5
Name: testjam-client
Version: 1.1.2
Summary: Python SDK and Robot Framework listener for the Testjam test management server.
Project-URL: Homepage, https://github.com/jamofer/testjam
Project-URL: Source, https://github.com/jamofer/testjam/tree/master/testjam-client
Project-URL: Issues, https://github.com/jamofer/testjam/issues
License-Expression: MIT
License-File: LICENSE
Classifier: Framework :: Robot Framework
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.12
Requires-Dist: httpx>=0.27
Provides-Extra: all
Requires-Dist: click-repl>=0.3; extra == 'all'
Requires-Dist: platformdirs>=4.2; extra == 'all'
Requires-Dist: rich>=13.7; extra == 'all'
Requires-Dist: robotframework>=7.0; extra == 'all'
Requires-Dist: tomli-w>=1.0; extra == 'all'
Requires-Dist: typer>=0.12; extra == 'all'
Provides-Extra: cli
Requires-Dist: click-repl>=0.3; extra == 'cli'
Requires-Dist: platformdirs>=4.2; extra == 'cli'
Requires-Dist: rich>=13.7; extra == 'cli'
Requires-Dist: tomli-w>=1.0; extra == 'cli'
Requires-Dist: typer>=0.12; extra == 'cli'
Provides-Extra: dev
Requires-Dist: click-repl>=0.3; extra == 'dev'
Requires-Dist: fastapi[standard]>=0.115; extra == 'dev'
Requires-Dist: platformdirs>=4.2; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: rich>=13.7; extra == 'dev'
Requires-Dist: robotframework>=7.0; extra == 'dev'
Requires-Dist: tomli-w>=1.0; extra == 'dev'
Requires-Dist: typer>=0.12; extra == 'dev'
Provides-Extra: robot-listener
Requires-Dist: robotframework>=7.0; extra == 'robot-listener'
Description-Content-Type: text/markdown

# testjam-client

Python SDK + Robot Framework listener + `testjam` command-line client for the Testjam REST API. One package, opt-in extras for the listener and the CLI.

## Install

```bash
# SDK only (Python integration)
pip install -e .

# SDK + CLI (the `testjam` binary)
pip install -e ".[cli]"

# SDK + Robot Framework listener
pip install -e ".[robot-listener]"

# Everything
pip install -e ".[all]"
```

Or pin from a local checkout:

```toml
dependencies = ["testjam-client @ file:///path/to/testjam-client"]
```

## Quick start

```python
from testjam_client import TestjamClient

with TestjamClient("http://localhost:8000/api/v1") as client:
    client.login("admin", "admin123")

    project = client.projects.find_or_create("My Project")
    version = client.versions.find_or_create(project["id"], "master-abc1234")

    suite = client.suites.find_or_create(project["id"], "Smoke Tests")
    case = client.cases.find_or_create(suite["id"], "Login flow")
    client.cases.replace_steps(case["id"], [
        {"action": "open page", "expected_result": "form visible"},
        {"action": "submit credentials", "expected_result": "redirect"},
    ])

    execution = client.executions.create(
        project["id"],
        title="CI build #42",
        type="automatic",
        test_case_ids=[case["id"]],
        version_id=version["id"],
    )
```

## Authentication

```python
# Bearer token (preferred for CI)
TestjamClient(url, token="eyJ...")

# Per-project API key
TestjamClient(url, api_key="tjk_...")

# Username + password (interactive / dev)
client = TestjamClient(url)
client.login("user", "pass")
```

## CLI quick start

The `[cli]` extra installs a `testjam` binary backed by Typer + Rich.

```bash
pip install "testjam-client[cli]"

testjam config set url https://testjam.example.com/api/v1
testjam login --username alice            # password prompt (hidden)
testjam config set default_project "Web"  # avoid repeating --project

testjam project list
testjam case create "Login" --suite 17 --steps -
testjam case import cases.csv           # one row per case; exit 1 on row errors
testjam run start "Nightly" --plan 5 --type automatic --yes
testjam run tail 91 --timeout 3600        # exit 0/1/2/3/4 = passed/failed/aborted/timed out/server unreachable
testjam run rerun 91 --not-passed --yes   # new run with the cases that did not pass

# Pipeline-friendly output:
testjam --json bug list --status open | jq '.[].title'
```

Drop the args to enter the REPL:

```
$ testjam
testjam> project list
testjam> --json bug list --severity high
testjam> :exit
```

Full reference: [`docs/manual/cli.md`](../docs/manual/cli.md).

## Resource modules

Responses are plain dicts described by `TypedDict` classes in
`testjam_client.models` (the package ships `py.typed`), and status values
live in `testjam_client.statuses`.

- `client.projects` — list, create, delete, `find_or_create`.
- `client.suites` — hierarchy: `descendants`, `parent_chain`, `path`,
  `case_ids_recursive`, `find_or_create`.
- `client.cases` — CRUD, steps (`list_steps`, `add_step`, `update_step`,
  `delete_step`, `reorder_steps`, `replace_steps`,
  `delete_steps_by_type`), archive (`archive`, `unarchive`),
  bulk reconciliation (`reconcile(suite_id, specs)`), `import_csv`.
- `client.versions` — CRUD + `find_or_create` keyed by name.
- `client.environments` — CRUD + `find_or_create`.
- `client.executions` — CRUD, `reopen`, `rerun`, `list_results` (filter by
  `assigned_to_id`), `bulk_results`,
  `import_junit` / `import_robotframework`, `export_xlsx` / `export_html`,
  `upload_attachment` / `list_attachments`.
- `client.results` — `get`, `create`, `update`, `assign`, `upload_attachment` /
  `list_attachments`.
- `client.step_results` — `start`, `update`, `append_log`.
- `client.bugs` — CRUD, `get_by_number`, `change_status`, comments,
  watchers (`watch` / `unwatch` / `list_watchers`), links, activity,
  attachments, `context`, `download_report`, `download_release_notes`.
- `client.plans` — CRUD test plans plus `add_cases`.
- `client.webhooks` — CRUD, `test`, `list_deliveries` (create returns
  the secret; subsequent reads omit it).
- `client.tokens` — `list_user_tokens` / `create_user_token` /
  `rotate_user_token` / `delete_user_token`, plus the
  `*_project_token` equivalents for project-scoped API keys.
- `client.integrations` — provider catalogue, project integrations,
  bug external links, `report_from_result`.
- `client.public_reports` — `create`, `list`, `revoke`, `fetch_html`.
- `client.users` — `me`.
  Generates anonymous share tokens for bug or execution reports.

## Errors

Every non-2xx response raises a subclass of `TestjamError`:

```python
from testjam_client import NotFound, Conflict, ValidationError, Unauthorized

try:
    client.projects.get(99999)
except NotFound as exc:
    print(exc.detail)

try:
    client.projects.create("Existing")
except Conflict:
    pass
```

## Tests

Tests live in `testjam-client/tests` and run against the real FastAPI app via
`fastapi.testclient.TestClient` with SQLite in-memory:

```bash
make test-client
```
