Skip to content

Commit f84eaed

Browse files
committed
docs(fixtures): add test project with SVCs, tests, pytest junit config and reqstool status instructions
1 parent ed2105b commit f84eaed

File tree

7 files changed

+135
-0
lines changed

7 files changed

+135
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# mypackage
2+
3+
Minimal test project for manual validation of `reqstool-python-hatch-plugin`.
4+
5+
## Prerequisites
6+
7+
A `.venv` must exist inside this directory with the plugin, Hatch, pytest, and reqstool installed.
8+
If it is missing, recreate it from `tests/fixtures/test_project/`:
9+
10+
```bash
11+
python3.13 -m venv .venv
12+
.venv/bin/pip install -e ../../../ # install plugin in editable mode
13+
.venv/bin/pip install hatch pytest reqstool
14+
```
15+
16+
## Validation
17+
18+
Run all commands from `tests/fixtures/test_project/`.
19+
20+
### 1 — Run tests
21+
22+
```bash
23+
.venv/bin/pytest tests/ --junit-xml=build/test-results/junit.xml -v
24+
```
25+
26+
Expected: `test_hello` passes.
27+
28+
### 2 — Build
29+
30+
```bash
31+
HATCH_ENV_TYPE_VIRTUAL_PATH=.venv .venv/bin/hatch build
32+
```
33+
34+
Expected output (sdist phase):
35+
1. `[reqstool] plugin <x.y.z> loaded`
36+
2. `[reqstool] added reqstool_config.yml to dist/mypackage-0.1.0.tar.gz`
37+
38+
### 3 — Check artefacts
39+
40+
```bash
41+
# annotations.yml must exist locally
42+
test -f build/reqstool/annotations.yml && echo "OK: annotations.yml"
43+
44+
# reqstool_config.yml must NOT be in project root (injected directly into tarball)
45+
test ! -f reqstool_config.yml && echo "OK: no loose reqstool_config.yml"
46+
47+
# sdist must contain reqstool_config.yml and dataset files
48+
tar -tzf dist/mypackage-0.1.0.tar.gz | sort
49+
```
50+
51+
Expected entries in the sdist:
52+
- `mypackage-0.1.0/reqstool_config.yml`
53+
- `mypackage-0.1.0/docs/reqstool/requirements.yml`
54+
- `mypackage-0.1.0/docs/reqstool/software_verification_cases.yml`
55+
56+
Note: unlike the poetry plugin, hatch injects `reqstool_config.yml` directly into the tarball
57+
and does not bundle `annotations.yml` — those are generated locally in `build/reqstool/`.
58+
59+
### 4 — Run reqstool status
60+
61+
Extract the sdist and merge in the local build outputs, then run `reqstool status`:
62+
63+
```bash
64+
mkdir -p /tmp/mypackage-reqstool
65+
tar -xzf dist/mypackage-0.1.0.tar.gz -C /tmp/mypackage-reqstool
66+
mkdir -p /tmp/mypackage-reqstool/mypackage-0.1.0/build/reqstool
67+
mkdir -p /tmp/mypackage-reqstool/mypackage-0.1.0/build/test-results
68+
cp build/reqstool/annotations.yml /tmp/mypackage-reqstool/mypackage-0.1.0/build/reqstool/
69+
cp build/test-results/junit.xml /tmp/mypackage-reqstool/mypackage-0.1.0/build/test-results/
70+
.venv/bin/reqstool status local -p /tmp/mypackage-reqstool/mypackage-0.1.0
71+
```
72+
73+
Expected: all green — `REQ_001` implemented, `T1 P1`, no missing tests or SVCs.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/requirements.schema.json
2+
3+
metadata:
4+
urn: mypackage
5+
variant: microservice
6+
title: Mypackage Requirements
7+
url: https://github.com/reqstool/reqstool-python-hatch-plugin
8+
9+
requirements:
10+
- id: REQ_001
11+
title: Hello function
12+
significance: shall
13+
description: The hello function shall return "hello".
14+
categories: ["functional-suitability"]
15+
revision: "0.1.0"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/reqstool/reqstool-client/main/src/reqstool/resources/schemas/v1/software_verification_cases.schema.json
2+
3+
cases:
4+
- id: SVC_001
5+
requirement_ids: ["REQ_001"]
6+
title: "Hello function returns hello"
7+
verification: automated-test
8+
revision: "0.1.0"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[build-system]
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling"]
4+
5+
[project]
6+
name = "mypackage"
7+
version = "0.1.0"
8+
description = "Minimal test project for reqstool-python-hatch-plugin"
9+
requires-python = ">=3.13"
10+
11+
[tool.hatch.build.targets.sdist]
12+
include = ["src", "docs/reqstool"]
13+
14+
[tool.pytest.ini_options]
15+
addopts = ["--import-mode=importlib"]
16+
pythonpath = ["src"]
17+
testpaths = ["tests"]
18+
junit_family = "xunit2"
19+
20+
[tool.hatch.build.hooks.reqstool]
21+
dependencies = ["reqstool-python-hatch-plugin"]
22+
sources = ["src", "tests"]
23+
test_results = ["build/**/junit.xml"]
24+
dataset_directory = "docs/reqstool"
25+
output_directory = "build/reqstool"

tests/fixtures/test_project/src/mypackage/__init__.py

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from reqstool_python_decorators.decorators.decorators import Requirements
2+
3+
4+
@Requirements("REQ_001")
5+
def hello():
6+
return "hello"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from reqstool_python_decorators.decorators.decorators import SVCs
2+
3+
from mypackage.main import hello
4+
5+
6+
@SVCs("SVC_001")
7+
def test_hello():
8+
assert hello() == "hello"

0 commit comments

Comments
 (0)