marionette-test 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- marionette_test-0.1.0/.gitignore +218 -0
- marionette_test-0.1.0/CHANGELOG.md +44 -0
- marionette_test-0.1.0/LICENSE +21 -0
- marionette_test-0.1.0/PKG-INFO +104 -0
- marionette_test-0.1.0/README.md +69 -0
- marionette_test-0.1.0/pyproject.toml +79 -0
- marionette_test-0.1.0/src/marionette/test/__init__.py +7 -0
- marionette_test-0.1.0/src/marionette/test/__main__.py +6 -0
- marionette_test-0.1.0/src/marionette/test/action.py +97 -0
- marionette_test-0.1.0/src/marionette/test/api/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/api/routes/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/api/routes/features.py +78 -0
- marionette_test-0.1.0/src/marionette/test/api/routes/runs.py +51 -0
- marionette_test-0.1.0/src/marionette/test/api/routes/swagger.py +54 -0
- marionette_test-0.1.0/src/marionette/test/api/server.py +56 -0
- marionette_test-0.1.0/src/marionette/test/cli.py +233 -0
- marionette_test-0.1.0/src/marionette/test/config/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/config/env.py +127 -0
- marionette_test-0.1.0/src/marionette/test/engine/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/engine/action_loader.py +53 -0
- marionette_test-0.1.0/src/marionette/test/engine/action_runtime.py +78 -0
- marionette_test-0.1.0/src/marionette/test/engine/assertion.py +210 -0
- marionette_test-0.1.0/src/marionette/test/engine/db_executor.py +279 -0
- marionette_test-0.1.0/src/marionette/test/engine/doctor.py +140 -0
- marionette_test-0.1.0/src/marionette/test/engine/http_client.py +95 -0
- marionette_test-0.1.0/src/marionette/test/engine/report_writer.py +67 -0
- marionette_test-0.1.0/src/marionette/test/engine/runner.py +463 -0
- marionette_test-0.1.0/src/marionette/test/engine/vars.py +136 -0
- marionette_test-0.1.0/src/marionette/test/engine/workspace_init.py +49 -0
- marionette_test-0.1.0/src/marionette/test/model/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/model/case.py +55 -0
- marionette_test-0.1.0/src/marionette/test/model/common.py +57 -0
- marionette_test-0.1.0/src/marionette/test/model/feature_unit.py +132 -0
- marionette_test-0.1.0/src/marionette/test/model/result.py +71 -0
- marionette_test-0.1.0/src/marionette/test/report/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/storage/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/storage/yaml_io.py +65 -0
- marionette_test-0.1.0/src/marionette/test/swagger/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/swagger/diff.py +65 -0
- marionette_test-0.1.0/src/marionette/test/swagger/fetcher.py +45 -0
- marionette_test-0.1.0/src/marionette/test/swagger/parser.py +100 -0
- marionette_test-0.1.0/src/marionette/test/workspace_template/__init__.py +1 -0
- marionette_test-0.1.0/src/marionette/test/workspace_template/actions_init.template +15 -0
- marionette_test-0.1.0/src/marionette/test/workspace_template/env.yml.template +38 -0
- marionette_test-0.1.0/src/marionette/test/workspace_template/gitignore.template +16 -0
- marionette_test-0.1.0/src/marionette/test/workspace_template/readme.template +23 -0
- marionette_test-0.1.0/web/README.md +29 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/), and the project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-06-19
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- Initial package skeleton: `marionette.test` namespace, typer-based CLI with
|
|
13
|
+
`init` / `config` / `doctor` / `run` / `serve` subcommands.
|
|
14
|
+
- `marionette.test.action` public API: `@action` decorator, in-process registry,
|
|
15
|
+
and `Context` / `RequestView` / `ResponseView` dataclasses for user-authored hooks.
|
|
16
|
+
- Pydantic v2 model layer for `FeatureUnit` / `Sheet` / `Case` / `Endpoint` /
|
|
17
|
+
`TableInsert` / `SqlStatement` with consistency validators.
|
|
18
|
+
- Round-trip YAML I/O (`storage/yaml_io.py`) using ruamel.yaml so user edits keep
|
|
19
|
+
comments and key order.
|
|
20
|
+
- Workspace configuration loader (`config/env.py`) reading `config/env.yml`,
|
|
21
|
+
resolving secrets from env vars.
|
|
22
|
+
- Execution engine: variable substitution (`engine/vars.py`), assertion engine
|
|
23
|
+
with JSONPath body rules (`engine/assertion.py`), synchronous HTTP client wrapper
|
|
24
|
+
(`engine/http_client.py`), and PostgreSQL baseline + clone + insert pipeline
|
|
25
|
+
(`engine/db_executor.py`).
|
|
26
|
+
- Custom action loader (`engine/action_loader.py`) that imports `actions/*.py` and
|
|
27
|
+
action runtime (`engine/action_runtime.py`) with fail-fast / best-effort hook
|
|
28
|
+
policies at four timings.
|
|
29
|
+
- Runner (`engine/runner.py`) iterating Feature → Sheet → Case with all 4 action
|
|
30
|
+
hooks, depends_on gating, evidence directory provisioning, and JSON `RunReport`
|
|
31
|
+
output (`engine/report_writer.py`).
|
|
32
|
+
- Swagger fetcher + parser ($ref expansion) + endpoint-level diff
|
|
33
|
+
(`swagger/{fetcher,parser,diff}.py`).
|
|
34
|
+
- FastAPI server (`api/server.py`) with `/api/features`, `/api/swagger`, `/api/runs`
|
|
35
|
+
routes and optional static UI mount from `web_dist/`.
|
|
36
|
+
- React + Vite frontend in `web/` covering Features list/edit, Swagger endpoints,
|
|
37
|
+
Run history, Run detail.
|
|
38
|
+
- Workspace initializer (`engine/workspace_init.py`) and read-only doctor
|
|
39
|
+
(`engine/doctor.py`) with six checks.
|
|
40
|
+
- CI (`.github/workflows/ci.yml`) and tag-driven release pipeline
|
|
41
|
+
(`.github/workflows/release.yml`) plus `scripts/bump_version.py`.
|
|
42
|
+
- 68 unit tests covering models, YAML I/O, variable substitution, assertions,
|
|
43
|
+
action runtime, runner, Swagger parsing/diff, workspace init, doctor, FastAPI
|
|
44
|
+
feature routes, and `bump_version`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 luvMagi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: marionette-test
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automated API testing tool for Spring projects, with custom action hooks and Essay-compatible evidence layout
|
|
5
|
+
Project-URL: Homepage, https://pypi.org/project/marionette-test/
|
|
6
|
+
Project-URL: Repository, https://github.com/luvmagi/marionette-test
|
|
7
|
+
Project-URL: Changelog, https://github.com/luvmagi/marionette-test/blob/main/CHANGELOG.md
|
|
8
|
+
Author-email: luvmagi <luvmagi@outlook.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Software Development :: Testing
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Requires-Dist: fastapi>=0.110
|
|
18
|
+
Requires-Dist: httpx>=0.27
|
|
19
|
+
Requires-Dist: jsonpath-ng>=1.6
|
|
20
|
+
Requires-Dist: jsonschema>=4.21
|
|
21
|
+
Requires-Dist: psycopg2-binary>=2.9
|
|
22
|
+
Requires-Dist: pydantic>=2.6
|
|
23
|
+
Requires-Dist: questionary>=2.0
|
|
24
|
+
Requires-Dist: rich>=13.7
|
|
25
|
+
Requires-Dist: ruamel-yaml>=0.18
|
|
26
|
+
Requires-Dist: typer>=0.12
|
|
27
|
+
Requires-Dist: uvicorn>=0.27
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: hatch>=1.9; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
33
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# marionette-test
|
|
37
|
+
|
|
38
|
+
Automated API testing tool for Spring projects, with custom action hooks and an
|
|
39
|
+
Essay-compatible evidence layout.
|
|
40
|
+
|
|
41
|
+
> Alpha — V1 backend-API surface is implemented and tested. See
|
|
42
|
+
> `docs/marionette-test/` for the design specs and `docs/guides/` for user-facing
|
|
43
|
+
> documentation.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install marionette-test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd <your-project>
|
|
55
|
+
marionette-test init # scaffold workspace
|
|
56
|
+
$EDITOR config/env.yml # point at your backend + DB
|
|
57
|
+
export DB_PASSWORD=... API_BEARER_TOKEN=...
|
|
58
|
+
marionette-test doctor # six read-only checks
|
|
59
|
+
marionette-test run # execute every FeatureUnit
|
|
60
|
+
marionette-test serve # FastAPI + UI on :8765
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
A complete walk-through is in [docs/guides/01-getting-started.md](docs/guides/01-getting-started.md).
|
|
64
|
+
|
|
65
|
+
## User guides
|
|
66
|
+
|
|
67
|
+
| Guide | What it covers |
|
|
68
|
+
| --------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
69
|
+
| [01 — Getting Started](docs/guides/01-getting-started.md) | Install, scaffold, write & run your first test |
|
|
70
|
+
| [02 — Writing FeatureUnits](docs/guides/02-feature-units.md) | Full YAML schema reference |
|
|
71
|
+
| [03 — Custom Actions](docs/guides/03-custom-actions.md) | `@action`, `Context`, 4 hook timings |
|
|
72
|
+
| [04 — Database Baseline](docs/guides/04-database-baseline.md) | `pg_dump` / `pg_restore` / clone lifecycle |
|
|
73
|
+
| [05 — CLI Reference](docs/guides/05-cli-reference.md) | Every subcommand and flag |
|
|
74
|
+
| [06 — Variables & Assertions](docs/guides/06-variables-and-assertions.md) | `${...}` grammar, `expect.*` rule grammar |
|
|
75
|
+
|
|
76
|
+
## Develop locally
|
|
77
|
+
|
|
78
|
+
This repo uses [uv](https://github.com/astral-sh/uv) for environment management.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
uv sync # create .venv and install runtime + dev deps
|
|
82
|
+
uv run marionette-test --version
|
|
83
|
+
uv run pytest # full test suite
|
|
84
|
+
uv run ruff check src/ tests/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Build a wheel locally:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
uv run hatch build # produces dist/*.whl + *.tar.gz
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Build the React UI (output lands inside the Python package so the wheel ships
|
|
94
|
+
it):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
cd web
|
|
98
|
+
npm install
|
|
99
|
+
npm run build # → src/marionette/test/web_dist/
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# marionette-test
|
|
2
|
+
|
|
3
|
+
Automated API testing tool for Spring projects, with custom action hooks and an
|
|
4
|
+
Essay-compatible evidence layout.
|
|
5
|
+
|
|
6
|
+
> Alpha — V1 backend-API surface is implemented and tested. See
|
|
7
|
+
> `docs/marionette-test/` for the design specs and `docs/guides/` for user-facing
|
|
8
|
+
> documentation.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install marionette-test
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cd <your-project>
|
|
20
|
+
marionette-test init # scaffold workspace
|
|
21
|
+
$EDITOR config/env.yml # point at your backend + DB
|
|
22
|
+
export DB_PASSWORD=... API_BEARER_TOKEN=...
|
|
23
|
+
marionette-test doctor # six read-only checks
|
|
24
|
+
marionette-test run # execute every FeatureUnit
|
|
25
|
+
marionette-test serve # FastAPI + UI on :8765
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A complete walk-through is in [docs/guides/01-getting-started.md](docs/guides/01-getting-started.md).
|
|
29
|
+
|
|
30
|
+
## User guides
|
|
31
|
+
|
|
32
|
+
| Guide | What it covers |
|
|
33
|
+
| --------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
34
|
+
| [01 — Getting Started](docs/guides/01-getting-started.md) | Install, scaffold, write & run your first test |
|
|
35
|
+
| [02 — Writing FeatureUnits](docs/guides/02-feature-units.md) | Full YAML schema reference |
|
|
36
|
+
| [03 — Custom Actions](docs/guides/03-custom-actions.md) | `@action`, `Context`, 4 hook timings |
|
|
37
|
+
| [04 — Database Baseline](docs/guides/04-database-baseline.md) | `pg_dump` / `pg_restore` / clone lifecycle |
|
|
38
|
+
| [05 — CLI Reference](docs/guides/05-cli-reference.md) | Every subcommand and flag |
|
|
39
|
+
| [06 — Variables & Assertions](docs/guides/06-variables-and-assertions.md) | `${...}` grammar, `expect.*` rule grammar |
|
|
40
|
+
|
|
41
|
+
## Develop locally
|
|
42
|
+
|
|
43
|
+
This repo uses [uv](https://github.com/astral-sh/uv) for environment management.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv sync # create .venv and install runtime + dev deps
|
|
47
|
+
uv run marionette-test --version
|
|
48
|
+
uv run pytest # full test suite
|
|
49
|
+
uv run ruff check src/ tests/
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Build a wheel locally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv run hatch build # produces dist/*.whl + *.tar.gz
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Build the React UI (output lands inside the Python package so the wheel ships
|
|
59
|
+
it):
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd web
|
|
63
|
+
npm install
|
|
64
|
+
npm run build # → src/marionette/test/web_dist/
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "marionette-test"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Automated API testing tool for Spring projects, with custom action hooks and Essay-compatible evidence layout"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "luvmagi", email = "luvmagi@outlook.com" },
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.11"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Topic :: Software Development :: Testing",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"fastapi>=0.110",
|
|
24
|
+
"uvicorn>=0.27",
|
|
25
|
+
"httpx>=0.27",
|
|
26
|
+
"ruamel.yaml>=0.18",
|
|
27
|
+
"jsonschema>=4.21",
|
|
28
|
+
"jsonpath-ng>=1.6",
|
|
29
|
+
"psycopg2-binary>=2.9",
|
|
30
|
+
"pydantic>=2.6",
|
|
31
|
+
"typer>=0.12",
|
|
32
|
+
"rich>=13.7",
|
|
33
|
+
"questionary>=2.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = [
|
|
38
|
+
"pytest>=8.0",
|
|
39
|
+
"pytest-asyncio>=0.23",
|
|
40
|
+
"ruff>=0.4",
|
|
41
|
+
"hatch>=1.9",
|
|
42
|
+
"twine>=5.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
marionette-test = "marionette.test.cli:main"
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://pypi.org/project/marionette-test/"
|
|
50
|
+
Repository = "https://github.com/luvmagi/marionette-test"
|
|
51
|
+
Changelog = "https://github.com/luvmagi/marionette-test/blob/main/CHANGELOG.md"
|
|
52
|
+
|
|
53
|
+
# ---- hatchling build configuration ----
|
|
54
|
+
|
|
55
|
+
[tool.hatch.build.targets.wheel]
|
|
56
|
+
# Ship the whole `marionette` PEP 420 namespace; only the `test` subpackage exists for now.
|
|
57
|
+
packages = ["src/marionette"]
|
|
58
|
+
|
|
59
|
+
# Embed the Vite build output into the wheel. Re-enable from M5 onward, when web/dist exists.
|
|
60
|
+
# [tool.hatch.build.targets.wheel.force-include]
|
|
61
|
+
# "web/dist" = "marionette/test/web_dist"
|
|
62
|
+
|
|
63
|
+
[tool.hatch.build.targets.sdist]
|
|
64
|
+
include = [
|
|
65
|
+
"src/marionette",
|
|
66
|
+
"README.md",
|
|
67
|
+
"LICENSE",
|
|
68
|
+
"CHANGELOG.md",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
# ---- tooling ----
|
|
72
|
+
|
|
73
|
+
[tool.ruff]
|
|
74
|
+
line-length = 100
|
|
75
|
+
target-version = "py311"
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
testpaths = ["tests"]
|
|
79
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Public API for user-authored custom actions.
|
|
2
|
+
|
|
3
|
+
Users put `.py` files under `<workspace>/actions/` and decorate functions with `@action`.
|
|
4
|
+
At runtime `marionette.test.engine.action_loader` imports those modules, which causes
|
|
5
|
+
`@action` to register each function in a module-level registry. The runner then dispatches
|
|
6
|
+
by name on the four hook points (pre_feature / post_feature / pre / post).
|
|
7
|
+
|
|
8
|
+
Actions are pure side-effect functions — return values are ignored. Outputs should be
|
|
9
|
+
written under `ctx.evidence_dir` so the Essay module can pick them up.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from dataclasses import dataclass, field
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any, Callable, Optional
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# --- registry ---------------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
_REGISTRY: dict[str, Callable[..., None]] = {}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def action(fn: Callable[..., None]) -> Callable[..., None]:
|
|
25
|
+
"""Register *fn* in the global action registry.
|
|
26
|
+
|
|
27
|
+
The function is returned untouched so it can still be imported and called directly
|
|
28
|
+
(handy for unit tests of action logic).
|
|
29
|
+
"""
|
|
30
|
+
name = fn.__name__
|
|
31
|
+
if name in _REGISTRY and _REGISTRY[name] is not fn:
|
|
32
|
+
raise ValueError(
|
|
33
|
+
f"action name conflict: '{name}' is already registered "
|
|
34
|
+
f"by {_REGISTRY[name].__module__}"
|
|
35
|
+
)
|
|
36
|
+
_REGISTRY[name] = fn
|
|
37
|
+
return fn
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_registry() -> dict[str, Callable[..., None]]:
|
|
41
|
+
"""Return a *copy* of the current registry — engine uses this as a snapshot."""
|
|
42
|
+
return dict(_REGISTRY)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def reset_registry() -> None:
|
|
46
|
+
"""Drop every registered action. Used by the reload endpoint and tests."""
|
|
47
|
+
_REGISTRY.clear()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# --- runtime context --------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dataclass
|
|
54
|
+
class RequestView:
|
|
55
|
+
"""Read-only snapshot of the rendered HTTP request, exposed to actions."""
|
|
56
|
+
|
|
57
|
+
method: str = ""
|
|
58
|
+
url: str = ""
|
|
59
|
+
path: dict[str, Any] = field(default_factory=dict)
|
|
60
|
+
query: dict[str, Any] = field(default_factory=dict)
|
|
61
|
+
header: dict[str, str] = field(default_factory=dict)
|
|
62
|
+
body: Any = None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class ResponseView:
|
|
67
|
+
"""Read-only snapshot of the HTTP response, exposed to `post_actions`."""
|
|
68
|
+
|
|
69
|
+
status: int = 0
|
|
70
|
+
header: dict[str, str] = field(default_factory=dict)
|
|
71
|
+
body: Any = None
|
|
72
|
+
elapsed_ms: float = 0.0
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@dataclass
|
|
76
|
+
class Context:
|
|
77
|
+
"""Runtime context passed as the first positional argument of every action.
|
|
78
|
+
|
|
79
|
+
Feature-level hooks (`pre_feature_actions` / `post_feature_actions`) see the feature-scoped
|
|
80
|
+
fields only; the per-case fields (`sheet`, `case_id`, `evidence_dir`, `request`, `response`)
|
|
81
|
+
stay at their defaults.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
feature_id: str
|
|
85
|
+
workspace_dir: Path
|
|
86
|
+
vars: dict[str, Any]
|
|
87
|
+
db: Any = None # psycopg2 connection (autocommit) to the cloned work DB
|
|
88
|
+
|
|
89
|
+
# Case-scoped — defaults make these safe to access in feature-level hooks too.
|
|
90
|
+
sheet: str = ""
|
|
91
|
+
sheet_name: str = ""
|
|
92
|
+
case_id: str = ""
|
|
93
|
+
evidence_dir: Optional[Path] = None
|
|
94
|
+
request: Optional[RequestView] = None
|
|
95
|
+
response: Optional[ResponseView] = None
|
|
96
|
+
|
|
97
|
+
logger: Any = None
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""FastAPI routers consumed by the React UI."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""API route modules."""
|