Metadata-Version: 2.1
Name: partest-gen
Version: 1.1.0
Summary: Scaffold a runnable pytest suite from OpenAPI: endpoints, payloads, validations and the priority-one test matrix partest's methodology asks for.
Home-page: https://github.com/Dec01/partest-gen
Author: dec01
Author-email: parshin.ewgeniy@yandex.ru
License: MIT
Project-URL: Source, https://github.com/Dec01/partest-gen
Project-URL: Issues, https://github.com/Dec01/partest-gen/issues
Project-URL: Changelog, https://github.com/Dec01/partest-gen/blob/master/CHANGELOG.md
Project-URL: Documentation, https://github.com/Dec01/partest-gen/blob/master/docs/wiki/index.md
Project-URL: PyPI, https://pypi.org/project/partest-gen/
Project-URL: partest, https://github.com/Dec01/partest
Keywords: autotest api openapi scaffold generator partest pytest codegen
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Pytest
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: partest >=2.1.0
Requires-Dist: pyyaml >=6.0.2
Requires-Dist: requests >=2.33.0
Provides-Extra: dev
Requires-Dist: pytest >=9.0.3 ; extra == 'dev'

# partest-gen

Turn an OpenAPI document into a **runnable pytest suite**: endpoints, payloads, validations,
collection facades, and the priority-one test matrix that
[partest](https://pypi.org/project/partest/)'s coverage methodology asks each operation for.

```bash
pip install partest-gen
```

`partest` comes with it — the generated suite runs on that harness. Python 3.10+.

## One command

```bash
partest-gen from-openapi ./my-suite --file openapi.yaml --depth p1 --with-ui
cd my-suite && pytest src/api/tests --collect-only -q
```

A green collect means every emitted module imports and every case is discovered. That is the
acceptance test for a generation; the rest of the work is writing the assertions.

## What you get

```text
my-suite/
├── requirements/{base,api,ui,local}.txt
├── confpartest.py, conftest.py, env.example, pytest.ini
├── .partest/{suite_ir.json, openapi_summary.md}
└── src/
    ├── api/
    │   ├── resources/{endpoints,payloads,validations,collections,rbac,security}
    │   └── tests/{conftest, test_zorro, <tag>/…}
    └── ui/                    # with --with-ui: pages, fixtures, baselines, tests
```

- **Classified operations.** Each endpoint gets a method subtype, and the subtype decides
  which test cases it needs. The classification comes from `partest.methodology`, so the
  generator and the coverage report never disagree about what an endpoint is.
- **Stubs with the right shape.** Every emitted call carries an explicit `type=` and lands in
  the correct cell of the coverage matrix. Most are skipped with a `TODO` — a generated
  assertion that passes on any response would raise the coverage number without testing
  anything.
- **Facades instead of strings.** `models.<tag>.paths.*`, `.payload.*()`, `.validate.*` —
  regenerated with the specification, so they cannot drift away from it.
- **A per-tag checklist.** `P1_CHECKLIST.md` and `.partest/openapi_summary.md` are the backlog.
- **An isolated UI tree.** `src/ui` never loads OpenAPI or the API coverage session.

## Commands

```bash
partest-gen from-openapi ./suite --file openapi.yaml --depth p1   # or --url
partest-gen sync-openapi ./suite --depth p1                        # the spec changed
partest-gen init-ui      ./suite                                   # add the UI tree later
partest-gen dump-ir      openapi.yaml -o suite_ir.json             # inspect, write nothing
partest-gen --version
```

| `--depth` | Emits |
|---|---|
| `resources` | paths + collection facades |
| `default` | + payloads, validations, Default and NotAllowed tests |
| `p1` | + the full priority-one stub set, plus a checklist per tag |

## Your files stay yours

Files the generator owns start with `AUTO-GENERATED by partest-gen`. `sync-openapi` rewrites
those and nothing else; files without the banner are left alone unless you pass `--force`.

So do not hand-edit a banner file — the edit survives until the next sync and then vanishes.
Put your code in a sibling module and import it.

## Documentation

Source and issues: **https://github.com/Dec01/partest-gen**

The user-facing pages also ship **inside the package**, so they are readable in the terminal
where you are actually running the tool:

```bash
python -m partest_gen.docs list                 # what is available
python -m partest_gen.docs show howto-scaffold  # read a page
python -m partest_gen.docs path                 # where the files live
```

Included: the first run end to end, turning stubs into tests, re-syncing after the spec
changes, the contract of generated code, the parts of the generator, and the UI layer.

## Requirements

Python 3.10+, `partest>=2.0.0`, `pyyaml`, `requests` (only for `--url`). The generated UI tree
additionally needs `pip install 'partest[ui]'` and a Playwright browser.

## License

MIT.
